示例#1
0
PPSDATA *rd_pps(FILE *ppsfp)
{
	char line[128], word[24], dc;
	long npps, mpps;
	int ip;
	PPSDATA *pps;
	
	npps = 0;
    mpps = 100;
	pps = (PPSDATA *) malloc(sizeof(PPSDATA));
	pps->time = (float *) malloc(100L * sizeof(float));
	pps->voic = (int *) malloc(100L * sizeof(int));
	while (fgets(line, 128, ppsfp)) {
		ip = 0;
		dcs(" ", &ip, line, word, &dc);
		pps->time[npps] = (float) atof(word);
		dcs(" ", &ip, line, word, &dc);
		dcs(" ", &ip, line, word, &dc);
		pps->voic[npps] = atoi(word) == 1;
		npps++;
		if (npps == mpps) {
			mpps += 100;
			pps->time = (float *) realloc((char *)pps->time, mpps * (long) sizeof(float));
			pps->voic = (int *) realloc((char *)pps->voic, mpps * (long) sizeof(int));
		}
	}
	pps->npps = npps;
	pps->mpps = mpps;
	return pps;
}
示例#2
0
    boost::system::error_code mms_socket::init_request() {

        mmsdcs_ = dcs()->context(MMS_OID);


        if (!mmsdcs_ || !mmsdcs_->valid())
            return boost::itu::ER_PROTOCOL;

        MMS::MMSpdu mms;
        mms.initiate_RequestPDU__new();
        MMS::Initiate_RequestPDU& initpdu = *mms.initiate_RequestPDU();

        initpdu.localDetailCalling(30000);
        initpdu.proposedMaxServOutstandingCalling(1);
        initpdu.proposedMaxServOutstandingCalled(5);
        initpdu.proposedDataStructureNestingLevel(5);
        initpdu.initRequestDetail().proposedVersionNumber (1);
        initpdu.initRequestDetail().servicesSupportedCalling(MMS_SERVICE_OPTOION_SUPPORT);
        initpdu.initRequestDetail().proposedParameterCBB(MMS_CBB_OPTION_SUPPORT);

        mmsdcs()->set(mms);

        return boost::system::error_code();

    }
示例#3
0
//_________________________________________________________________________________________________
void GroupByChamber(AliMergeableCollection& hc, int timeResolution)
{
  for ( Int_t ich = 1; ich <= 10; ++ich )
  {
    AliMpDEIterator it;
  
    it.First(ich-1);
  
    TH1* hchamberLeft(0x0);
    TH1* hchamberRight(0x0);
    TList listLeft;
    TList listRight;
    listLeft.SetOwner(kFALSE);
    listRight.SetOwner(kFALSE);
    
    AliMpDCSNamer dcs("TRACKER");

    while (!it.IsDone())
    {
      Int_t detElemId = it.CurrentDEId();

       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
    
      TH1* h = hc.Histo(Form("/DE/HITS/%ds/DE%04d",timeResolution,detElemId));
      
      if (dcs.DCSAliasName(detElemId).Contains("Left"))
      {
        if (!hchamberLeft)
        {
          hchamberLeft = static_cast<TH1*>(h->Clone(Form("CHAMBER%dLEFT",ich)));
        }
        else
        {
          listLeft.Add(h);
        }
      }
      else
      {
        if (!hchamberRight)
        {
          hchamberRight = static_cast<TH1*>(h->Clone(Form("CHAMBER%dRIGHT",ich)));
        }
        else
        {
          listRight.Add(h);
        }
      }
      
      it.Next();
    }
    
    hchamberLeft->Merge(&listLeft);
    hchamberRight->Merge(&listRight);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamberLeft);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamberRight);
    TH1* hchamber = static_cast<TH1*>(hchamberLeft->Clone(Form("CHAMBER%d",ich)));
    hchamber->Add(hchamberRight);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamber);
  }
}
示例#4
0
void MenuTreeTest::runTests()
{
  menuTree->build();
  WsTreeSerializer mts(menuTree);
  assert(mts.serialize() == SUCCESS);
  WsTreeDeserializer mtds(mts.getSerializedForm());
  assert(mtds.deserialize() == SUCCESS);
  cout << "Path for root in " << mtds.getMenuRoot()->getFullPath() << endl;
  assert(mtds.getMenuRoot()->getPath() == "/");
  assert( mtds.getMenuRoot()->getDirectories().size() == 2);
  WsDirNode* root = static_cast<WsDirNode*>(mtds.getMenuRoot());
  WsDirNode* test1 = static_cast<WsDirNode*>(root->getDirectories().front());
  assert(test1->getName() == "test1");
  assert(test1->getDirectories().size() == 3);
  WsDirNode* test3 = static_cast<WsDirNode*>(root->getDirectories().back());
  assert(test3->getName() == "test3");
  assert(test3->getDirectories().size() == 0);
  set<string> groups;
  groups.insert("Guest");
  string p("test1/");
  WsDirContentsSerializer dcs(fsTree , groups, p );
  assert(dcs.serialize() == SUCCESS);
  WsDirContentsDeserializer dcds(dcs.getSerializedForm());
  dcds.deserialize();
  assert(dcds.getContents().size() == 2);
  WsDirNode* products = static_cast<WsDirNode*>(dcds.getContents().front());
  assert( products->getName() == "products");
  WsDirNode* references = static_cast<WsDirNode*>(dcds.getContents().back());
  assert( references->getName() == "references");
  assert(products->getDirectories().size() == 0);
}
示例#5
0
void MTProtoSession::start(int32 dcenter, uint32 connects) {
	if (dcId) {
		DEBUG_LOG(("Session Info: MTProtoSession::start called on already started session"));
		return;
	}
	if (connects < 1) {
		connects = cConnectionsInSession();
	} else if (connects > 4) {
		connects = 4;
	}
	
	msSendCall = msWait = 0;

	connect(&timeouter, SIGNAL(timeout()), this, SLOT(checkRequestsByTimer()));
	timeouter.start(1000);

	connect(&sender, SIGNAL(timeout()), this, SIGNAL(needToSend()));
	connect(this, SIGNAL(startSendTimer(int)), &sender, SLOT(start(int)));
	connect(this, SIGNAL(stopSendTimer()), &sender, SLOT(stop()));
	connect(this, SIGNAL(needToSendAsync()), this, SIGNAL(needToSend()));

	MTProtoDCMap &dcs(mtpDCMap());

	connections.reserve(connects);
	for (uint32 i = 0; i < connects; ++i) {	
		connections.push_back(new MTProtoConnection());
		dcId = connections.back()->start(&data, dcenter);
		if (!dcId) {
			for (MTProtoConnections::const_iterator j = connections.cbegin(), e = connections.cend(); j != e; ++j) {
				delete *j;
			}
			connections.clear();
			DEBUG_LOG(("Session Info: could not start connection %1 to dc %2").arg(i).arg(dcenter));
			return;
		}
		if (!dc) {
			dcenter = dcId;
			MTProtoDCMap::const_iterator dcIndex = dcs.constFind(dcId % _mtp_internal::dcShift);
			if (dcIndex == dcs.cend()) {
				dc = MTProtoDCPtr(new MTProtoDC(dcId % _mtp_internal::dcShift, mtpAuthKeyPtr()));
				dcs.insert(dcId % _mtp_internal::dcShift, dc);
			} else {
				dc = dcIndex.value();
			}

			ReadLockerAttempt lock(keyMutex());
			data.setKey(lock ? dc->getKey() : mtpAuthKeyPtr(0));
			if (lock && dc->connectionInited()) {
				data.setLayerWasInited(true);
			}
			connect(dc.data(), SIGNAL(authKeyCreated()), this, SLOT(authKeyCreatedForDC()));
			connect(dc.data(), SIGNAL(layerWasInited(bool)), this, SLOT(layerWasInitedForDC(bool)));
		}
	}
示例#6
0
	/**
	 * @memberof class ABWT< ABSequence<std::string> >
	 * @brief 建構式與程式主體
	 * @param sequence ABSequence<std::string> 原始待排序序列
	 * @param dcs_size uint32_t dcs 參數,攸關dcs大小速度
	 * @param interval_size uint32_t 在建abwt表時所使用的間隔參數,越小越快,記憶體使用越大
	 */
	ABWT (SeqType &sequence, uint32_t dcs_size=512, uint32_t interval_size=64, std::string prefixName="")
		:seq(sequence), len_seq(seq.size()) , dcs_v(dcs_size), abwtt(interval_size), split_size(30000000), _prefixName {prefixName}

	{

		//part 1
		/// @brief 測試
		start = clock();
		// make dcs table
		DIFFERENCE_COVER < SeqType, PreSortType > dcs(seq, dcs_v);

		std::function<bool(INTTYPE, INTTYPE)> dcs_compare_func = std::bind( &DIFFERENCE_COVER < SeqType, PreSortType >::compare, dcs, std::placeholders::_1, std::placeholders::_2);

		stop = clock();
		std::clog << "===================================" << std::endl;
		std::clog << "Create dcs table, time:" << double(stop - start) / CLOCKS_PER_SEC << std::endl;
		std::clog << "===================================" << std::endl;


		//part 2

		start = clock();

		// sort suffix using split sort
		std::cout << "split_size : " << split_size << std::endl;
		//new split sort obj


		Split_sort<	SeqType, std::vector< INTTYPE >, MainSortType > split_sort (seq,dcs_v);
		//setting
		split_sort.getTableV = [](INTTYPE& a){
			return a;
		};
		split_sort.dcs_compare = dcs_compare_func;
		//start split sort
		split_sort.split_by_size_init(split_size);

		// copy sorted result to seq_table(bwt)
		//seq_table.reserve( seq.size() );
		//seq_table.swap(split_sort.Results);
		std::vector<std::string> filenames = split_sort.archive_name;

		//release dcs memory
		std::cout << "release dcs..." << std::endl;
		dcs.release();
		std::cout << "release split sort..." << std::endl;
		split_sort.release();


		stop = clock();
		std::clog << "===================================" << std::endl;
		std::clog << "Create BWT, time:" << double(stop - start) / CLOCKS_PER_SEC << std::endl;
		std::clog << "===================================" << std::endl;


		//part 3

		start = clock();
		// save abwt table

		abwtt.createAllTable(seq, filenames);
		//abwtt.saveBWT("t_bwt.bwt");
		//abwtt.saveTable("t_table.bwt");
		//abwtt.saveSEQ("t_seq.bwt", seq);
		abwtt.saveBWT( _prefixName + "t_bwt.bwt");
		abwtt.saveTable( _prefixName + "t_table.bwt");
		abwtt.saveSEQ( _prefixName + "t_seq.bwt", seq);


		stop = clock();
		std::clog << "===================================" << std::endl;
		std::clog << "Create abwt Table, time:" << double(stop - start) / CLOCKS_PER_SEC << std::endl;
		std::clog << "===================================" << std::endl;

		split_sort.clean_up ();

		return ;

	}
示例#7
0
//_________________________________________________________________________________________________
void FillNumberOfPads(AliMergeableCollection& hc)
{
  // number of pads needed for normalization

  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
  AliMpBusPatch* bp;

  Int_t total(0);
  
  AliMpDCSNamer dcs("TRACKER");
  
  while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
  {
    TH1* h = new TH1F(Form("BP%04d",bp->GetId()),"number of pads",1,0,1);
    
    Int_t npads(0);
    
    Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId());
    
    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
    
    for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
    {
      Int_t manuId = bp->GetManuId(i);
      
      npads += de->NofChannelsInManu(manuId);
    }
    
    TH1* hde = hc.Histo(Form("/DE/NPADS/DE%04d",detElemId));
    if (!hde)
    {
        hde = new TH1F(Form("DE%04d",detElemId),"number of pads",1,0,1);
        hc.Adopt("/DE/NPADS/",hde);
    }
    hde->Fill(0.0,1.0*npads);
    
    Int_t ddlId = de->GetDdlId() + AliDAQ::DdlIDOffset("MUONTRK");
    
    TH1* hddl = hc.Histo(Form("/DDL/NPADS/DDL%d",ddlId));
    if (!hddl)
    {
      hddl = new TH1F(Form("DDL%d",ddlId),"number of pads",1,0,1);
      hc.Adopt("/DDL/NPADS/",hddl);
    }
    hddl->Fill(0.0,1.0*npads);
    
    Int_t chamberId = 1+AliMpDEManager::GetChamberId(detElemId);
    Int_t stationId = 1 + AliMpDEManager::GetChamberId(detElemId)/2;
    
    TH1* hchamberSide(0x0);
    TH1* hstationSide(0x0);
    
    if (dcs.DCSAliasName(detElemId).Contains("Left"))
    {
      hchamberSide = hc.Histo(Form("/CHAMBER/NPADS/CHAMBER%dLEFT",chamberId));
      if (!hchamberSide)
      {
        hchamberSide = new TH1F(Form("CHAMBER%dLEFT",chamberId),"number of pads",1,0,1);
        hc.Adopt("/CHAMBER/NPADS/",hchamberSide);
      }
      hstationSide = hc.Histo(Form("/STATION/NPADS/STATION%dLEFT",stationId));
      if (!hstationSide)
      {
        hstationSide = new TH1F(Form("STATION%dLEFT",stationId),"number of pads",1,0,1);
        hc.Adopt("/STATION/NPADS/",hstationSide);
      }
    }
    else
    {
      if (dcs.DCSAliasName(detElemId).Contains("Right"))
      {
        hchamberSide = hc.Histo(Form("/CHAMBER/NPADS/CHAMBER%dRIGHT",chamberId));
        if (!hchamberSide)
        {
          hchamberSide = new TH1F(Form("CHAMBER%dRIGHT",chamberId),"number of pads",1,0,1);
          hc.Adopt("/CHAMBER/NPADS/",hchamberSide);
        }
        hstationSide = hc.Histo(Form("/STATION/NPADS/STATION%dRIGHT",stationId));
        if (!hstationSide)
        {
          hstationSide = new TH1F(Form("STATION%dRIGHT",stationId),"number of pads",1,0,1);
          hc.Adopt("/STATION/NPADS/",hstationSide);
        }
      }
    }

    hchamberSide->Fill(0.0,1.0*npads);
    hstationSide->Fill(0.0,1.0*npads);
    
    TH1* hchamber = hc.Histo(Form("/CHAMBER/NPADS/CHAMBER%d",chamberId));
    if (!hchamber)
    {
      hchamber = new TH1F(Form("CHAMBER%d",chamberId),"number of pads",1,0,1);
      hc.Adopt("/CHAMBER/NPADS/",hchamber);
    }
    hchamber->Fill(0.0,1.0*npads);

    TH1* hstation = hc.Histo(Form("/STATION/NPADS/STATION%d",stationId));
    if (!hstation)
    {
      hstation = new TH1F(Form("STATION%d",stationId),"number of pads",1,0,1);
      hc.Adopt("/STATION/NPADS/",hstation);
    }
    hstation->Fill(0.0,1.0*npads);

    h->Fill(0.0,1.0*npads);
    
    total += npads;
    
    hc.Adopt("/BUSPATCH/NPADS/",h);
  }
  
  std::cout << "Total pads=" << total << std::endl;
  
}