void getChannel(char *epicsSetupFile,Char_t *PVName){ Char_t* name="epicsTest"; //name for the module FILE* log=NULL; //no logging here Char_t line[120]; //line for AcquDAQ to set up the module void *out = fEventBuff; //pointer to the event buffer if(!loaded)loadLibs(); //load the libs if required TEPICSmodule *epics; //Epics module sprintf(line,"dummy dummy dummy timer 370"); //create the setup line mode timer 0.37s period epics = new TEPICSmodule(name,epicsSetupFile,log,line); //create a module epics->FileConfig(epicsSetupFile); //configure with the setup file epics->PostInit(); //do the post init epics->WriteEPICS(&out); //do the actual readout epics->GetChannel(PVName, &type, fEventBuff, outbuff, &nElem); fprintf(stdout,"\nPV: %s, type: %s, nElement: %d \n", PVName,epicsTypeName[type],nElem); for(int n=0;n<nElem;n++){ fprintf(stdout,"%s[%d] = %f\n",PVName,n,outbuff[n]); } delete epics; }
extern "C" NS_EXPORT int ChildProcessInit(int argc, char* argv[]) { int i; for (i = 0; i < (argc - 1); i++) { if (strcmp(argv[i], "-greomni")) continue; i = i + 1; break; } fillLibCache(argv[argc - 1]); loadLibs(argv[i]); // don't pass the last arg - it's only recognized by the lib cache argc--; typedef GeckoProcessType (*XRE_StringToChildProcessType_t)(char*); typedef nsresult (*XRE_InitChildProcess_t)(int, char**, GeckoProcessType); XRE_StringToChildProcessType_t fXRE_StringToChildProcessType = (XRE_StringToChildProcessType_t)__wrap_dlsym(xul_handle, "XRE_StringToChildProcessType"); XRE_InitChildProcess_t fXRE_InitChildProcess = (XRE_InitChildProcess_t)__wrap_dlsym(xul_handle, "XRE_InitChildProcess"); GeckoProcessType proctype = fXRE_StringToChildProcessType(argv[--argc]); nsresult rv = fXRE_InitChildProcess(argc, argv, proctype); if (rv != 0) return 1; return 0; }
bool LuaState::init() { if (plua_state_) return false; plua_state_ = luaL_newstate(); loadLibs(); return true; }
extern "C" NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_loadLibs(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName, jboolean jShouldExtract) { if (jShouldExtract) extractLibs = 1; const char* str; // XXX: java doesn't give us true UTF8, we should figure out something // better to do here str = jenv->GetStringUTFChars(jApkName, NULL); if (str == NULL) return; loadLibs(str); jenv->ReleaseStringUTFChars(jApkName, str); }
void getBufferInfo(char *epicsSetupFile){ Char_t* name="epicsTest"; //name for the module FILE* log=NULL; //no logging here Char_t line[120]; //line for AcquDAQ to set up the module void *out = fEventBuff; //pointer to the event buffer if(!loaded)loadLibs(); //load the libs if required TEPICSmodule *epics; //Epics module sprintf(line,"dummy dummy dummy timer 370"); //create the setup line mode timer 0.37s period epics = new TEPICSmodule(name,epicsSetupFile,log,line); //create a module // epics->SetVerbose(kTRUE); epics->FileConfig(epicsSetupFile); //configure with the setup file epics->PostInit(); //do the post init epics->WriteEPICS(&out); //do the actual readout epics->GetBufferInfo(&index, &id, EventName, &nchan,fEventBuff, ×tamp); fprintf(stderr, "index: %hd, id: %hd, EventName: %s, nchan: %hd, time: %s\n",index,id,EventName,nchan,asctime(localtime(×tamp))); delete epics; }
int getTaggerInfo(){ Char_t pv[100]; Int_t epicsErr=0; if(!libsLoaded)loadLibs(); //load the libs if required random = new TRandom1(); //The names of the channels for scalers and emaps are stored in CBREM ioc as stringout PVs. //Get the names here sprintf(pv,"%sHODO_EMAP_NAME", Prefix); epicsErr += epicsGet(pv,kEpicsSTRING,1,HodoEmapPV); cout << pv << " = " << HodoEmapPV << endl; sprintf(pv,"%sHODO_SCALER_NAME", Prefix); epicsErr += epicsGet(pv,kEpicsSTRING,1,HodoScalerPV); cout << pv << " = " << HodoScalerPV << endl; sprintf(pv,"%sMICRO_EMAP_NAME", Prefix); epicsErr += epicsGet(pv,kEpicsSTRING,1,MicroEmapPV); cout << pv << " = " << MicroEmapPV << endl; sprintf(pv,"%sMICRO_SCALER_NAME",Prefix); epicsErr += epicsGet(pv,kEpicsSTRING,1,MicroScalerPV); cout << pv << " = " << MicroScalerPV << endl; sprintf(pv,"%sLOWG_SCALER_NAME", Prefix); epicsErr += epicsGet(pv,kEpicsSTRING,1,LowGScalerPV); cout << pv << " = " << LowGScalerPV << endl; // figure out which of these things is getting used sprintf(pv,"%sHODO_STATE", Prefix); epicsErr += epicsGet(pv,kEpicsDOUBLE,1,&HodoStateD); HodoState = (Int_t)HodoStateD; cout << pv << " = " << HodoState << endl; sprintf(pv,"%sMICRO_STATE", Prefix); epicsErr += epicsGet(pv,kEpicsDOUBLE,1,&MicroStateD); MicroState = (Int_t)MicroStateD; cout << pv << " = " << MicroState << endl; sprintf(pv,"%sLOWG_STATE", Prefix); epicsErr += epicsGet(pv,kEpicsDOUBLE,1,&LowGStateD); LowGState = (Int_t)LowGStateD; cout << pv << " = " << LowGState << endl; sprintf(IndexPV,"%sRADIATOR_INDEX",Grefix); //This is the only info that comes from the GONI ioc sprintf(RadiatorPV,"%sRADIATOR_ID",Grefix); //This is the only info that comes from the GONI ioc sprintf(ReqEdgePV,"%sREQ_EDGE",Prefix); sprintf(EdgeMapPV,"%sEDGE_LINE_MAP",Prefix); sprintf(EdgePV,"%sEDGE",Prefix); sprintf(RawScalerPV,"%sRAW_SCALERS",Prefix); sprintf(AmoScalerPV,"%sAMO_SCALERS",Prefix); sprintf(EnhScalerPV,"%sENH_SCALERS",Prefix); sprintf(DeadScalerPV,"%sDEAD_SCALERS",Prefix); sprintf(NormEnergyPV,"%sNORM_ENERGY",Prefix); sprintf(RefPV,"%sENH_REF",Prefix); sprintf(HeartbeatPV,"%sHEARTBEAT",Prefix); if(epicsErr){ cout << "FATAL ERROR reading EPICS Channels. Exiting." << endl; return -1; } if(HodoState){ //read no of hodo elements sprintf(pv,"%s.NELM",HodoEmapPV); epicsGet(pv,kEpicsLONG,1,&nHodo); epicsGet(HodoEmapPV, kEpicsDOUBLE, nHodo, HodoEmap); //make bins for hodo histogram cout << "pv=" << pv << ", nHodo =" << nHodo << endl; for(int n=1;n<nHodo-1;n++) HodoBins[n]=0.5*(HodoEmap[n-1]+HodoEmap[n]); HodoBins[0] = HodoBins[1] - (HodoBins[2] - HodoBins[1]); HodoBins[nHodo-1] = HodoBins[nHodo-2] + (HodoBins[nHodo-2] - HodoBins[nHodo-3]); HodoBins[nHodo] = HodoBins[nHodo-1] + (HodoBins[nHodo-1] - HodoBins[nHodo-2]); hHodo = new TH1D("hHodo", "Hodoscope Scalers;E_{g}/MeV", nHodo, HodoBins); //make the hists hHodo->SetMinimum(0); hHodo->SetStats(0); HodoScaler = hHodo->GetArray()+1; //point to 1st bin of histogram epics will read straight to here if(sim){ //if sim, make hists for simulated data hHodoS = new TH1D("hHodoS", "Hodoscope Scalers Sim;E_{g}/MeV", nHodo, HodoBins); hHodoS->SetMinimum(0);hHodoS->SetStats(0); HodoScalerS = hHodoS->GetArray()+1; //point to 1st bin of histogram epics will write straight from here } } if(MicroState){ //read no of micro elements sprintf(pv,"%s.NELM",MicroEmapPV); epicsGet(pv,kEpicsLONG,1,&nMicro); epicsGet(MicroEmapPV, kEpicsDOUBLE, nMicro, MicroEmap); //make bins for micro histogram for(int n=1;n<nMicro-1;n++) MicroBins[n]=0.5*(MicroEmap[n-1]+MicroEmap[n]); MicroBins[0] = MicroBins[1] - (MicroBins[2] - MicroBins[1]); MicroBins[nMicro-1] = MicroBins[nMicro-2] + (MicroBins[nMicro-2] - MicroBins[nMicro-3]); MicroBins[nMicro] = MicroBins[nMicro-1] + (MicroBins[nMicro-1] - MicroBins[nMicro-2]); hMicro = new TH1D("hMicro","Microscope Scalers;E_{g}/MeV", nMicro,MicroBins); //make the hists hMicro->SetMinimum(0); hMicro->SetStats(0); MicroScaler = hMicro->GetArray()+1; //point to 1st bin of histogram epics will read straight to here if(sim){ //if sim, make hists for simulated data hMicroS = new TH1D("hMicroS","Microscope Scalers Sim;E_{g}/MeV", nMicro,MicroBins); hMicroS->SetMinimum(0);hMicroS->SetStats(0); MicroScalerS = hMicroS->GetArray()+1; //point to 1st bin of histogram epics will write straight from here } } //Figure out how to construct the full tagger spectrum from up to 3 components Emap[nChan++] = 1.0; //Make a 1.0 MeV point for low Energy scaler. if((!HodoState)&&(!MicroState)&&(!LowGState)){ cout << "FATAL ERROR No photon detectors enabled. Exiting." << endl; return -1; } if ((HodoState)&&(!MicroState)){ //Hodo only for(int n=0;n<nHodo;n++){ //Copy hodo channels to main Emap Emap[nChan++]=HodoEmap[n]; } } else if((!HodoState)&&(MicroState)){ //Micro only for(int n=0;n<nMicro;n++){ //Copy micro channels to main Emap Emap[nChan++]=MicroEmap[n]; } } else if((HodoState)&&(MicroState)){ //hodo and micro int h=0; while(HodoEmap[h]<MicroEmap[0]){ //use hodo until we hot the micro Emap[nChan++]=HodoEmap[h++]; } h--; HodoMin = h; for(int n=0;n<nMicro;n++){ //Copy micro channels to main Emap Emap[nChan++]=MicroEmap[n]; } while(HodoEmap[h++]<=MicroEmap[nMicro-1]); //get to 1st hodo chan greater than last micro chan h--; HodoMax=h; for(int n=HodoMax;n<nHodo;n++){ //Copy micro channels to main Emap Emap[nChan++]=HodoEmap[n]; } } //make bins for histograms //Like this: n 0 1 2 3 ... nChan //Emap = 1 2 40 46 //Ebins= 0 2 37 43 49 // n 0 1 2 3 4 ... nChan+1 //A histogram axis with a low energy bin and bin centres from the EMap. Ebins[0] = 0.0; Ebins[1] = 2.0; //Force a 0 MeV bin Ebins[2] = Emap[1]-0.5*(Emap[2]-Emap[1]); for(n=1;n<nChan-1;n++) Ebins[n+2] = 0.5*(Emap[n]+Emap[n+1]); Ebins[nChan+1] = Emap[nChan-1]+0.5*(Emap[nChan-1]-Emap[nChan-2]); hRaw = new TH1D("hRaw", "Raw Tagger Scalers;E_{g}/MeV", nChan+1, Ebins); //make the hists Raw = hRaw->GetArray()+1; hEnh = new TH1D("hEnh", "Tagger Enhancement;E_{g}/MeV", nChan+1, Ebins); Enh = hEnh->GetArray()+1; hAmo = new TH1D("hAmo", "Amorphous Scalers (Ref); E_{g}/MeV", nChan+1, Ebins); Amo = hAmo->GetArray()+1; hRef = new TH1D("hRef", "Tagger Enhancememt (Ref);E_{g}/MeV", nChan+1, Ebins); hRaw->SetMinimum(0); hRaw->SetStats(0); hEnh->SetMinimum(0); hEnh->SetStats(0); hAmo->SetMinimum(0); hAmo->SetStats(0); hRef->SetMinimum(0); hRef->SetStats(0); //Write these things out to EPICS sprintf(EmapPV,"%sEMAP",Prefix); epicsPut(EmapPV,kEpicsDOUBLE,nChan,Emap); nChanD = nChan; sprintf(NscalersPV,"%sN_SCALERS",Prefix); epicsPut(NscalersPV,kEpicsDOUBLE,1,&nChanD); taggerLoaded=kTRUE; //flag that all the stuff is loaded up CbremCanvas = new TCanvas("CbremCanvas","CbremCanvas",20,20,800,600); return 0; }
ClientSettings::ClientSettings(ClientInterface* par) { m_parent = par; setParent(par); setWhatsThis(tr("Ici, vous pouvez régler bon nombre d'options du logiciel.")); setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowTitleHint|Qt::WindowCloseButtonHint|Qt::WindowContextHelpButtonHint); m_settings = allocateSettings(this); QVBoxLayout* la = new QVBoxLayout; QVBoxLayout* la2 = new QVBoxLayout; QHBoxLayout* hla= new QHBoxLayout; setLayout(hla); hla->addLayout(la); hla->addLayout(la2); { QGroupBox *gb = new QGroupBox(tr("Général")); la->addWidget(gb); QVBoxLayout* v_la = new QVBoxLayout; gb->setLayout(v_la); { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_nickname = new QLineEdit(m_settings->value(PARAM_NICK).toString(), this); m_nickname->setMaxLength(MAX_NICKNAME_LENGHT); m_nickname->setWhatsThis(tr("Entrez ici le pseudo que vous utiliserez sur le chat. A contrario de la commande /pseudo, ce pseudo sera automatiquement appliqué à chaque connexion.")); h_la->addWidget(new QLabel(tr("Pseudo :"))); h_la->addWidget(m_nickname); } } { QGroupBox *gb = new QGroupBox(tr("Interface")); la->addWidget(gb); QVBoxLayout* v_la = new QVBoxLayout; gb->setLayout(v_la); { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_selectInterface = new QPushButton("...", this); m_selectInterface->setWhatsThis(tr("Parcourir le disque dur...")); connect(m_selectInterface, SIGNAL(pressed()), this, SLOT(selectInterface())); m_interfacePath = new QLineEdit(m_settings->value(PARAM_INTERFACE, DEFAULT_INTERFACE).toString(), this); connect(m_interfacePath, SIGNAL(returnPressed()), this, SLOT(openInterface())); h_la->addWidget(m_interfacePath); h_la->addWidget(m_selectInterface); } { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_saveInterface = new QPushButton(tr("Sauvegarder"), this); m_saveInterface->setWhatsThis(tr("Sauvegarder une interface.")); connect(m_saveInterface, SIGNAL(pressed()), this, SLOT(saveInterface())); h_la->addWidget(m_saveInterface); m_openInterface = new QPushButton(tr("Charger"), this); m_openInterface->setWhatsThis(tr("Charger l'interface marquée plus haut.")); connect(m_openInterface, SIGNAL(pressed()), this, SLOT(openInterface())); h_la->addWidget(m_openInterface); } } { QGroupBox *gb = new QGroupBox(tr("Thème")); la->addWidget(gb); QVBoxLayout* v_la = new QVBoxLayout; gb->setLayout(v_la); QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_selectCSS = new QPushButton("...", this); m_selectCSS->setWhatsThis(tr("Parcourir le disque dur...")); connect(m_selectCSS, SIGNAL(pressed()), this, SLOT(selectCSS())); m_CSSPath = new QLineEdit(m_settings->value(PARAM_CSS).toString(), this); connect(m_CSSPath, SIGNAL(returnPressed()), this, SLOT(openCSS())); h_la->addWidget(m_CSSPath); h_la->addWidget(m_selectCSS); m_openCSS = new QPushButton(tr("Charger"), this); m_openCSS->setWhatsThis(tr("Charger la feuille de style indiquée plus haut.")); connect(m_openCSS, SIGNAL(pressed()), this, SLOT(openCSS())); v_la->addWidget(m_openCSS); } { QGroupBox *gb = new QGroupBox(tr("Paramètres de connexion")); gb->setWhatsThis(tr("Ces options ne sont disponibles que lorsque vous n'êtes pas connecté à un serveur.")); la->addWidget(gb); QVBoxLayout* v_la = new QVBoxLayout; gb->setLayout(v_la); v_la->addWidget(new QLabel(tr("Addresse IP et port du serveur :"))); QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_serverIP = new QLineEdit(m_settings->value(PARAM_IP, SERVER_IP).toString(), this); m_serverIP->setInputMask("000.000.000.000;"); m_serverPort = new QSpinBox(this); m_serverPort->setMinimum(1024); m_serverPort->setMaximum(65535); m_serverPort->setValue(m_settings->value(PARAM_PORT, SERVER_PORT).toInt()); h_la->addWidget(m_serverIP); h_la->addWidget(new QLabel(":")); h_la->addWidget(m_serverPort); if(par->isConnected()) gb->setEnabled(false); } { QGroupBox *gb = new QGroupBox(tr("Paramètres du son")); la2->addWidget(gb); QVBoxLayout* v_la = new QVBoxLayout; gb->setLayout(v_la); v_la->addWidget(new QLabel(tr("Volume des sons d'ambiance :"))); { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_sound = new QSlider(this); m_sound->setMaximum(1000); m_sound->setOrientation(Qt::Horizontal); m_sound->setValue(static_cast<int>(m_settings->value(PARAM_SOUND, 100.f).toFloat()*10)); connect(m_sound, SIGNAL(valueChanged(int)), this, SLOT(soundSliderChanged(int))); m_soundSpinBox=new QDoubleSpinBox(this); m_soundSpinBox->setMaximum(100); m_soundSpinBox->setMinimum(0); m_soundSpinBox->setMaximum(100); m_soundSpinBox->setDecimals(1); m_soundSpinBox->setValue(m_settings->value(PARAM_SOUND, 100.f).toFloat()); connect(m_soundSpinBox, SIGNAL(valueChanged(double)), this, SLOT(soundSpinBoxChanged(double))); h_la->addWidget(m_sound); h_la->addWidget(m_soundSpinBox); } { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); h_la->addWidget(new QLabel(tr("Périphériques sonore :"))); m_chb_dvc_out=new QCheckBox(tr("Utiliser le périphérique par défaut"), this); v_la->addWidget(m_chb_dvc_out); m_cb_dvc_out=new QComboBox(this); m_cb_dvc_out->addItems(getOALDevices(true)); m_cb_dvc_out->setCurrentIndex(m_cb_dvc_out->findText(getOALCurrentDevice(true))); h_la->addWidget(m_cb_dvc_out); } { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); h_la->addWidget(new QLabel(tr("Périphériques de capture :"))); m_chb_dvc_in=new QCheckBox(tr("Utiliser le périphérique par défaut"), this); v_la->addWidget(m_chb_dvc_in); m_cb_dvc_in=new QComboBox(this); m_cb_dvc_in->addItems(getOALDevices(false)); int ind=m_cb_dvc_in->findText(getOALCurrentDevice(false)); if(ind==-1) { QString d=getOALCurrentDevice(false); m_cb_dvc_in->addItem(d); m_cb_dvc_in->setCurrentIndex(m_cb_dvc_in->findText(d)); } else m_cb_dvc_in->setCurrentIndex(ind); h_la->addWidget(m_cb_dvc_in); } } { m_voip = new QGroupBox(tr("Paramètres de la VOIP")); m_voip->setCheckable(true); m_voip->setChecked(m_settings->value(PARAM_VOIP_ENABLED, true).toBool()); la2->addWidget(m_voip); QVBoxLayout* v_la = new QVBoxLayout; m_voip->setLayout(v_la); v_la->addWidget(new QLabel(tr("Volume de la reception :"))); { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_VOIPSound = new QSlider(this); m_VOIPSound->setMaximum(1000); m_VOIPSound->setOrientation(Qt::Horizontal); m_VOIPSound->setValue(static_cast<int>(m_settings->value(PARAM_VOIP_SOUND, 100.f).toFloat()*10)); connect(m_VOIPSound, SIGNAL(valueChanged(int)), this, SLOT(VOIPSoundSliderChanged(int))); m_VOIPSoundSpinBox=new QDoubleSpinBox(this); m_VOIPSoundSpinBox->setMaximum(100); m_VOIPSoundSpinBox->setMinimum(0); m_VOIPSoundSpinBox->setDecimals(1); m_VOIPSoundSpinBox->setValue(m_settings->value(PARAM_VOIP_SOUND, 100.f).toFloat()); connect(m_VOIPSoundSpinBox, SIGNAL(valueChanged(double)), this, SLOT(VOIPSoundSpinBoxChanged(double))); h_la->addWidget(m_VOIPSound); h_la->addWidget(m_VOIPSoundSpinBox); } v_la->addWidget(new QLabel(tr("Qualité de la VOIP (sortant) :"))); { QHBoxLayout* h_la = new QHBoxLayout; v_la->addLayout(h_la); m_VOIPQuality = new QSlider(this); m_VOIPQuality->setMinimum(1); m_VOIPQuality->setMaximum(100); m_VOIPQuality->setOrientation(Qt::Horizontal); m_VOIPQuality->setValue(static_cast<int>(m_settings->value(PARAM_VOIP_QUALITY, 4).toFloat()*10)); connect(m_VOIPQuality, SIGNAL(valueChanged(int)), this, SLOT(VOIPQualitySliderChanged(int))); h_la->addWidget(new QLabel(tr("Plus rapide"))); h_la->addWidget(m_VOIPQuality); h_la->addWidget(new QLabel(tr("Plus clair"))); } } { QGroupBox *gb = new QGroupBox(tr("Bibliothèques de sons")); la2->addWidget(gb); QPushButton* m_libsListRefresh = new QPushButton(tr("Rafraichir"), this); connect(m_libsListRefresh, SIGNAL(pressed()), this, SLOT(refreshLibs())); QPushButton* m_libsListLoad = new QPushButton(tr("Charger"), this); connect(m_libsListLoad, SIGNAL(pressed()), this, SLOT(loadLibs())); QScrollArea* m_libsScroll=new QScrollArea(this); { QVBoxLayout* v = new QVBoxLayout; gb->setLayout(v); v->addWidget(m_libsListRefresh); v->addWidget(m_libsScroll); v->addWidget(m_libsListLoad); } m_libs_la = new QVBoxLayout; { gar=new QWidget(this); m_libsScroll->setWidget(gar); gar->setLayout(m_libs_la); } } { m_ok = new QPushButton(tr("Valider"), this); m_ok->setDefault(true); connect(m_ok, SIGNAL(pressed()), this, SLOT(ok())); m_cancel = new QPushButton(tr("Annuler"), this); connect(m_cancel, SIGNAL(pressed()), this, SLOT(reject())); QHBoxLayout* h_la = new QHBoxLayout; h_la->addWidget(m_ok); h_la->addWidget(m_cancel); la->addLayout(h_la); } refreshLibs(); }
void merge(TString outfile, TString firstfile, TString pat=defaultPattern) { TList decayModes; bool save=false; TString dir="."; TString first=""; long flags=0,id=0,size=0,modtime=0; if(firstfile.Contains("~")) { cout<<"ERROR: input path cannot contain '~' character."<<endl; return; } // Check pattern TRegexp pattern(pat,true); if(pattern.Status()!=0) { cout<<"ERROR: Wrong regular expression."<<endl; return; } // Load libraries loadLibs(); gSystem->GetPathInfo(firstfile, &id, &size, &flags, &modtime); bool isDirectory = flags&2; if(isDirectory) { dir=firstfile; first=""; } else { //Separate directory from filename int separator=firstfile.Last('/'); if(separator!=-1) dir=firstfile(0,separator+1); first=firstfile(separator+1,firstfile.Length()); } cout<<"Output file: "<<outfile<<endl; cout<<"Input dir: "<<dir<<endl; if(!isDirectory) cout<<"First file: "<<first<<endl; cout<<endl; // Get file list and add first file if present TList *files = getFileList(first,dir,pattern); if(!isDirectory) { TFile *ff = new TFile(firstfile,"READ"); files->AddBefore(files->First(),ff); } // Merge files TIter next(files); TFile *file; while(file = (TFile*)next()) { if(!file->IsOpen()) continue; ReadFile(file,decayModes); cout<<"=============================="<<endl; save=true; } // Save output if(save) { cout<<"Saving..."<<endl; SaveOutput(outfile,decayModes); cout<<"Output saved to "<<outfile<<endl<<endl; } else cout<<"Nothing to save."<<endl<<endl; // Closing files cout<<"Closing files..."<<endl; TIter cl(files); while(file = (TFile*)cl()) { file->Close(); delete file; } delete files; gSystem->Exit(0); }
void testEpics(char *epicsSetupFile, char* outfile=NULL, int singleOnly=0){ //epicsSetupFile is the name of the setup file for the EPICS module to be loaded in AcquDAQ Char_t* name="epicsTest"; //name for the module FILE* log=NULL; //no logging here Char_t line[120]; //line for AcquDAQ to set up the module void *out = fEventBuff; //pointer to the event buffer if(!loaded)loadLibs(); //load the libs if required TEPICSmodule *epics; //Epics module fprintf(stderr, "\n\n------- TESTING SINGE READOUT SHOT-----------\n"); sprintf(line,"dummy dummy dummy timer 0"); //create the setup line 0 period epics = new TEPICSmodule(name,epicsSetupFile,log,line); //create a module // epics->SetVerbose(kTRUE); epics->FileConfig(epicsSetupFile); //configure with the setup file epics->PostInit(); //do the post init epics->WriteEPICS(&out); //do the actual readout epics->DumpBuffer(fEventBuff,outfile); //Check that the buffer is good if(singleOnly){ delete epics; return; } fprintf(stderr, "\n\n------- TESTING TIMED PERIODIC READOUT MODE-----------\n"); epics->Start(); //start the timer for(int n=0;n<2;n++){ //do 2 events fprintf(stderr,"Event %d\n",n); if(epics->IsTimedOut()){ //check to see if timed out out = fEventBuff; //retes out every time since WriteEPICS(&out) moves it along the buffer epics->WriteEPICS(&out); //do the actual readout epics->DumpBuffer(fEventBuff,outfile); //Check that the buffer is good fprintf(stderr,"----- Read %d bytes from the EPICS buffer ----\n\n",out-fEventBuff); //count the bytes of the ptr in the buffer. epics->Start(); //restart the timer } gSystem->Sleep(500); } delete epics; sprintf(line,"dummy dummy dummy scaler 2"); //create the setup line mode scaler period = 2 scaler events epics = new TEPICSmodule(name,epicsSetupFile,log,line); //create a module // epics->SetVerbose(kTRUE); epics->FileConfig(epicsSetupFile); //configure with the setup file epics->PostInit(); //do the post init fprintf(stderr, "\n\n------- #SCALER EVENTS PERIODIC READOUT MODE-----------\n"); epics->Start(); //start the counter for(int n=0;n<5;n++){ //do 5 events fprintf(stderr,"Scaler Event %d\n",n); epics->Count(); //force a dummy scaler count if(epics->IsCountedOut()){ //check to see if count is reached out = fEventBuff; //reset out every time since WriteEPICS(&out) moves it along the buffer epics->WriteEPICS(&out); //do the actual readout epics->DumpBuffer(fEventBuff,outfile); //Check that the buffer is good fprintf(stderr,"----- Read %d bytes from the EPICS buffer ----\n\n",out-fEventBuff); //count the bytes of the ptr in the buffer. epics->Start(); //restart the counter } gSystem->Sleep(100); } delete epics; }
void EventManager::init() { loadLibs(); initEvents(); }
extern "C" NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_loadLibs(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName, jboolean jShouldExtract) { if (jShouldExtract) extractLibs = 1; const char* str; // XXX: java doesn't give us true UTF8, we should figure out something // better to do here str = jenv->GetStringUTFChars(jApkName, NULL); if (str == NULL) return; loadLibs(str); jenv->ReleaseStringUTFChars(jApkName, str); bool haveLibsToWrite = false; if (cache_mapping && extractLibs) for (int i = 0; i < cache_count && !haveLibsToWrite; i++) if (cache_mapping[i].buffer) haveLibsToWrite = true; int count = cache_count; struct lib_cache_info *info; if (haveLibsToWrite) { if (fork()) { // just unmap. fork will do the real work. while (count--) { info = &cache_mapping[count]; if (!info->buffer) continue; munmap(info->buffer, info->lib_size); } } else { sleep(10); nice(10); while (count--) { info = &cache_mapping[count]; if (!info->buffer) continue; char fullpath[PATH_MAX]; snprintf(fullpath, PATH_MAX, "%s/%s", getenv("CACHE_PATH"), info->name); char tmp_path[PATH_MAX]; sprintf(tmp_path, "%s.tmp", fullpath); int file_fd = open(tmp_path, O_CREAT | O_WRONLY); // using sendfile would be preferable, but it doesn't seem to work // with shared memory on any of the devices we've tested uint32_t sent = write(file_fd, info->buffer, info->lib_size); munmap(info->buffer, info->lib_size); info->buffer = 0; close(file_fd); if (sent == info->lib_size) rename(tmp_path, fullpath); else unlink(tmp_path); } exit(0); } } }