コード例 #1
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
ePipeline&   CSpace::GetProperty(){
	assert(Size()>5);
	assert(GetDataType(4) == TYPE_PIPELINE);
	ePipeline* Property = (ePipeline*)GetData(4);
	return *Property;
};
コード例 #2
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
SPACETYPE    CSpace::GetSpaceType(){
	assert(Size()>5);
	assert(GetDataType(2) == TYPE_INT);
	int64 Type =*(int64*)GetData(2);
	return (SPACETYPE)Type;
};
コード例 #3
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
tstring& CSpace::GetFingerprint(){
	assert(Size()>5);
	assert(GetDataType(3) == TYPE_STRING);
	tstring& Fingerprint = *(tstring*)GetData(3);
	return Fingerprint;	
}
コード例 #4
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
int64   CSpace::GetSpaceID(){
    assert(Size()>5);
	assert(GetDataType(0) == TYPE_INT);
	int64 SpaceID = *(int64*)GetData(0);
	return SpaceID;
};
コード例 #5
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
tstring  CSpace::GetName(){
	assert(Size()>5);
	assert(GetDataType(1)==TYPE_STRING);
	tstring* Name = (tstring*)GetData(1);
	return *Name;
};
コード例 #6
0
ファイル: sc-nagra.c プロジェクト: 3PO/vdr-plugin-sc
bool cSmartCardNagra::Init(void)
{
  block=0; isTiger=isT14Nagra=isN3=swapCW=false;
  caid=SYSTEM_NAGRA;
  ResetIdSet();

  static const unsigned char atrDNASP[] = { 'D','N','A','S','P' };
  static const unsigned char atrTIGER[] = { 'T','I','G','E','R' };
  static const unsigned char atrNCMED[] = { 'N','C','M','E','D' };
  static const unsigned char atrIRDET[] = { 'I','R','D','E','T','O' };
  if(!memcmp(atr->hist,atrDNASP,sizeof(atrDNASP))) {
    if(atr->hist[5]=='2' && atr->hist[6]=='4') isN3=true;
    PRINTF(L_SC_INIT,"detected native T1 nagra card (N%d Mode)",isN3?3:2);
    if(!SetIFS(0xFE)) return false;
    memcpy(rominfo,atr->hist,sizeof(rominfo));
    }
  else if(!memcmp(atr->hist,atrTIGER,sizeof(atrTIGER)) || !memcmp(atr->hist,atrNCMED,sizeof(atrNCMED))) {
    PRINTF(L_SC_INIT,"detected nagra tiger card");
    if(!SetIFS(0xFE)) return false;
    memcpy(rominfo,atr->hist,sizeof(rominfo));
    cardId=0xFFFFFFFF;
    isTiger=true;
    }
  else if(!memcmp(atr->hist,atrIRDET,sizeof(atrIRDET))) {
    PRINTF(L_SC_INIT,"detected tunneled T14 nagra card");
    if(!allowT14) {
      PRINTF(L_SC_INIT,"Nagra mode for T14 card disabled in setup");
      return false;
      }
    PRINTF(L_SC_INIT,"using nagra mode");
    isT14Nagra=true;
    if(!DoBlkCmd(0x10,0x02,0x90,0x11)) {
      PRINTF(L_SC_ERROR,"get rom version failed");
      return false;
      }
    memcpy(rominfo,&buff[2],15);
    }
  else {
    PRINTF(L_SC_INIT,"doesn't look like a nagra card");
    return false;
    }

  infoStr.Begin();
  infoStr.Strcat("Nagra smartcard\n");
  char rom[12], rev[12];
  snprintf(rom,sizeof(rom),"%c%c%c%c%c%c%c%c",rominfo[0],rominfo[1],rominfo[2],rominfo[3],rominfo[4],rominfo[5],rominfo[6],rominfo[7]);
  snprintf(rev,sizeof(rev),"%c%c%c%c%c%c",rominfo[9],rominfo[10],rominfo[11],rominfo[12],rominfo[13],rominfo[14]);
  PRINTF(L_SC_INIT,"rom version: %s revision: %s",rom,rev);
  infoStr.Printf("Rom %s Rev %s\n",rom,rev);

  if(!isTiger) {
    GetCardStatus();
    if(!DoBlkCmd(0x12,0x02,0x92,0x06) || !Status()) return false;
    cardId=UINT32_BE(buff+5);
    SetCard(new cCardNagra2(buff+5));

    if(!GetDataType(DT01,0x0E)) return false;
    GetCardStatus();
    if(!GetDataType(IRDINFO,0x39)) return false;
    GetCardStatus();
    if(!GetDataType(CAMDATA,0x55)) return false;
    GetCardStatus();
    if(!GetDataType(DT04,0x44)) return false;
    GetCardStatus();
    if(memcmp(rominfo+5,"181",3)!=0) { // not working on ROM181
      infoStr.Printf("Tiers\n");
      infoStr.Printf("|id  |chid| dates               |\n");
      infoStr.Printf("+----+----+---------------------+\n");
      if(!GetDataType(TIERS,0x57)) return false;
      GetCardStatus();
      }
    if(!GetDataType(DT06,0x16)) return false;
    GetCardStatus();
    }

  if(!HasCamMod()) {
    cSmartCardDataNagra cd(cardId,false);
    cSmartCardDataNagra *entry=(cSmartCardDataNagra *)smartcards.FindCardData(&cd);
    if(entry) {
      SetCardData(cardId,entry->bk,entry->exp);
      SetCamMod(entry->mod);
      }
    else {
      PRINTF(L_SC_ERROR,"can't find CARD modulus");
      return false;
      }
    }
  if(!DoCamExchange()) return false;
  infoStr.Finish();
  return true;
}
コード例 #7
0
ファイル: cio_DFI_AVS.C プロジェクト: kenoogl/CDMlib
// #################################################################
// ヘッダーデータファイルの出力
bool cio_DFI_AVS::write_avs_header()
{
  FILE* fp=NULL;
  std::string dType;
  std::string out_fname;

  bool mio=false;

  //データタイプのセット
  if( GetDataType() == CIO::E_CIO_INT8 ) {
    dType = "byte";
  } else if( GetDataType() == CIO::E_CIO_INT16 ) {
    dType = "short";
  } else if( GetDataType() == CIO::E_CIO_INT32 ) {
    dType = "integer";
  } else if( GetDataType() == CIO::E_CIO_FLOAT32 ) {
    dType = "float";
  } else if( GetDataType() == CIO::E_CIO_FLOAT64 ) {
    dType = "double";
  } else {
    dType = GetDataTypeString();
    printf("\tillergal data type.(%s)\n",dType.c_str());
    return false;
  }

  //ファイル名生成

  if( DFI_MPI.NumberOfRank > 1 ) mio = true;
  std::string fname,tmp;
  tmp = Generate_FileName(DFI_Finfo.Prefix,m_RankID,-1,"fld",m_output_fname,mio,
                          DFI_Finfo.TimeSliceDirFlag);
  if( CIO::cioPath_isAbsolute(DFI_Finfo.DirectoryPath) ){
    fname = DFI_Finfo.DirectoryPath +"/"+ tmp;
  } else {
    fname = m_directoryPath + "/" + DFI_Finfo.DirectoryPath +"/"+ tmp;
  }

  //printf("fld file name : %s\n",fname.c_str());

  //出力ヘッダーファイルオープン
  if( (fp = fopen(fname.c_str(),"w"))  == NULL ) {
    printf("\tCan't open file.(%s)\n",fname.c_str());
    return false;
  }

  int ndim = 3;
  int nspace = 3;
  //dims = DFI_Process.RankList[m_RankID].VoxelSize[0]

  //先頭レコードの出力
  fprintf(fp,"# AVS field file\n");

  //計算空間の次元数を出力
  fprintf(fp,"ndim=%d\n",ndim);

  //計算空間サイズを出力
  fprintf(fp,"dim1=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[0]+1);
  fprintf(fp,"dim2=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[1]+1);
  fprintf(fp,"dim3=%d\n",DFI_Process.RankList[m_RankID].VoxelSize[2]+1);

  //物理空間の次元数を出力
  fprintf(fp,"nspace=%d\n",nspace);

  //成分数の出力
  fprintf(fp,"veclen=%d\n",DFI_Finfo.Component);

  //データのタイプ出力
  fprintf(fp,"data=%s\n",dType.c_str());

  //座標定義情報の出力
  fprintf(fp,"field=uniform\n");

  //labelの出力
  for(int i=0; i<DFI_Finfo.Component; i++) {
    std::string label=getComponentVariable(i);
    if( label == "" ) continue;
    fprintf(fp,"label=%s\n",label.c_str());
  }

  //step毎の出力
  if( DFI_TimeSlice.SliceList.size()>1 ) {
    fprintf(fp,"nstep=%d\n",(int)DFI_TimeSlice.SliceList.size());
  }
  for(int i=0; i<DFI_TimeSlice.SliceList.size(); i++) {
    fprintf(fp,"time value=%.6f\n",DFI_TimeSlice.SliceList[i].time);

    //field data file name 出力
    for(int j=1; j<=DFI_Finfo.Component; j++) {
      int skip;
      if( dType == "float" ) {
        skip=96+(j-1)*4;
      } else {
        skip=140+(j-1)*8;
      }
      out_fname=Generate_FileName(DFI_Finfo.Prefix,
                                  m_RankID,
                                  DFI_TimeSlice.SliceList[i].step,
                                  "sph",
                                  m_output_fname,
                                  mio,
                                  DFI_Finfo.TimeSliceDirFlag);
      //std::string xxx = CIO::cioPath_FileName(out_fname,"sph");
      fprintf(fp,"variable %d file=%s filetype=binary skip=%d stride=%d\n",
              j,out_fname.c_str(),skip,DFI_Finfo.Component);
    }

    //coord data file name 出力
    tmp = Generate_FileName("cord",m_RankID,-1,"cod",m_output_fname,mio,
                            DFI_Finfo.TimeSliceDirFlag);
    fprintf(fp,"coord 1 file=%s filetype=ascii skip=1\n",tmp.c_str());
    fprintf(fp,"coord 2 file=%s filetype=ascii skip=4\n",tmp.c_str());
    fprintf(fp,"coord 3 file=%s filetype=ascii skip=7\n",tmp.c_str());
    fprintf(fp,"EOT\n");
    
  }

  //出力ヘッダーファイルクローズ
  fclose(fp);

  //if( tmp ) delete tmp;

  return true;
}
コード例 #8
0
ファイル: OGLTexture3D.cpp プロジェクト: dreamsxin/Urho3D
bool Texture3D::SetData(unsigned level, int x, int y, int z, int width, int height, int depth, const void* data)
{
    URHO3D_PROFILE(SetTextureData);

    if (!object_.name_ || !graphics_)
    {
        URHO3D_LOGERROR("No texture created, can not set data");
        return false;
    }

    if (!data)
    {
        URHO3D_LOGERROR("Null source for setting data");
        return false;
    }

    if (level >= levels_)
    {
        URHO3D_LOGERROR("Illegal mip level for setting data");
        return false;
    }

    if (graphics_->IsDeviceLost())
    {
        URHO3D_LOGWARNING("Texture data assignment while device is lost");
        dataPending_ = true;
        return true;
    }

    if (IsCompressed())
    {
        x &= ~3;
        y &= ~3;
    }

    int levelWidth = GetLevelWidth(level);
    int levelHeight = GetLevelHeight(level);
    int levelDepth = GetLevelDepth(level);
    if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || z < 0 || z + depth > levelDepth || width <= 0 ||
        height <= 0 || depth <= 0)
    {
        URHO3D_LOGERROR("Illegal dimensions for setting data");
        return false;
    }

    graphics_->SetTextureForUpdate(this);

#ifndef GL_ES_VERSION_2_0
    bool wholeLevel = x == 0 && y == 0 && z == 0 && width == levelWidth && height == levelHeight && depth == levelDepth;
    unsigned format = GetSRGB() ? GetSRGBFormat(format_) : format_;

    if (!IsCompressed())
    {
        if (wholeLevel)
            glTexImage3D(target_, level, format, width, height, depth, 0, GetExternalFormat(format_), GetDataType(format_), data);
        else
            glTexSubImage3D(target_, level, x, y, z, width, height, depth, GetExternalFormat(format_), GetDataType(format_), data);
    }
    else
    {
        if (wholeLevel)
            glCompressedTexImage3D(target_, level, format, width, height, depth, 0, GetDataSize(width, height, depth), data);
        else
            glCompressedTexSubImage3D(target_, level, x, y, z, width, height, depth, format, GetDataSize(width, height, depth),
                data);
    }
#endif

    graphics_->SetTexture(0, 0);
    return true;
}
コード例 #9
0
bool Texture2DArray::Create()
{
    Release();

#ifdef GL_ES_VERSION_2_0
    URHO3D_LOGERROR("Failed to create 2D array texture, currently unsupported on OpenGL ES 2");
    return false;
#else

    if (!graphics_ || !width_ || !height_ || !layers_)
        return false;

    if (graphics_->IsDeviceLost())
    {
        URHO3D_LOGWARNING("Texture array creation while device is lost");
        return true;
    }

    glGenTextures(1, &object_.name_);

    // Ensure that our texture is bound to OpenGL texture unit 0
    graphics_->SetTextureForUpdate(this);

    unsigned format = GetSRGB() ? GetSRGBFormat(format_) : format_;
    unsigned externalFormat = GetExternalFormat(format_);
    unsigned dataType = GetDataType(format_);

    // If not compressed, create the initial level 0 texture with null data
    bool success = true;
    if (!IsCompressed())
    {
        glGetError();
        glTexImage3D(target_, 0, format, width_, height_, layers_, 0, externalFormat, dataType, 0);
        if (glGetError())
            success = false;
    }
    if (!success)
        URHO3D_LOGERROR("Failed to create texture array");

    // Set mipmapping
    if (usage_ == TEXTURE_DEPTHSTENCIL)
        requestedLevels_ = 1;
    else if (usage_ == TEXTURE_RENDERTARGET)
    {
#ifdef __EMSCRIPTEN__
        // glGenerateMipmap appears to not be working on WebGL, disable rendertarget mipmaps for now
        requestedLevels_ = 1;
#else
        if (requestedLevels_ != 1)
        {
            // Generate levels for the first time now
            RegenerateLevels();
            // Determine max. levels automatically
            requestedLevels_ = 0;
        }
#endif
    }

    levels_ = CheckMaxLevels(width_, height_, requestedLevels_);
    glTexParameteri(target_, GL_TEXTURE_BASE_LEVEL, 0);
    glTexParameteri(target_, GL_TEXTURE_MAX_LEVEL, levels_ - 1);

    // Set initial parameters, then unbind the texture
    UpdateParameters();
    graphics_->SetTexture(0, 0);

    return success;
#endif
}
コード例 #10
0
void KVINDRAOnlineDataAnalyser::ProcessRun()
{
   // Perform treatment of a given run

   //Open data file
   fRunFile = (KVRawDataReader*)gDataSet->OpenRunfile(GetDataType().Data() , fRunNumber);
   if (fRunFile->GetStatus() == KVGRUNetClientGanilReader::kSTATUS_NOHOST) {
      // cannot connect to ACQ host
      Error("ProcessRun", "Cannot connect to acquisition host machine. Check KVGRUNetClientGanilReader.AcqHostName");
      return;
   }
   //warning! real number of run may be different from that deduced from file name
   //we get the real run number from gMultiDetArray and use it to name any new files
   fRunNumber = gMultiDetArray->GetCurrentRunNumber();

   fEventNumber = 0; //event number

   cout << endl << "Reading ONLINE events from RUN# " << fRunNumber << endl;

   cout << "Starting analysis of data on : ";
   TDatime now;
   cout <<  now.AsString() << endl << endl;

   preInitRun();
   //call user's beginning of run
   InitRun();
   postInitRun();

   fDetEv = new KVDetectorEvent;

   //loop over events in file
   fGoEventLoop = kTRUE;
   fDumpEvents = kFALSE;
   while (fGoEventLoop) {
      Bool_t gotevent = fRunFile->GetNextEvent();

      if (gotevent) {
         fEventNumber++;

         //reconstruct hit groups
         KVSeqCollection* fired = fRunFile->GetFiredDataParameters();
         gMultiDetArray->GetDetectorEvent(fDetEv, fired);

         preAnalysis();
         //call user's analysis. stop if returns kFALSE.
         if (!Analysis()) break;
         postAnalysis();

         fDetEv->Clear();

         if (!((fEventNumber) % 10000)) cout << " ++++ " << fEventNumber << " events read ++++ " << endl;
      } else {
         // got no event - why ?
         Int_t status = fRunFile->GetStatus();
         switch (status) {
            case KVGRUNetClientGanilReader::kSTATUS_NOBUFF:
               Warning("ProcessRun", "Got no buffer from ACQHOST. Sleeping for 2 seconds.");
               gSystem->Sleep(2000);
               break;

            case KVGRUNetClientGanilReader::kSTATUS_NOEVENT:
               Warning("ProcessRun", "Got no event from ACQHOST. Sleeping for 2 seconds.");
               gSystem->Sleep(2000);
               break;

            case KVGRUNetClientGanilReader::kSTATUS_NOACQ:
               Warning("ProcessRun", "Acquisition is stopped. Sleeping for 5 seconds.");
               gSystem->Sleep(5000);
               break;
         }
      }
   }

   delete fDetEv;

   cout << "Ending analysis of run " << fRunNumber << " on : ";
   TDatime now2;
   cout <<  now2.AsString() << endl << endl;
   cout << endl << "Finished reading " << fEventNumber << " events" << endl << endl;

   preEndRun();
   //call user's end of run function
   EndRun();
   postEndRun();

   if (fMessageThread) {
      fMessageThread->Kill();
      TThread::Delete(fMessageThread);
      delete fMessageThread;
      fMessageThread = 0;
   }
}