Beispiel #1
0
int
process_dii(struct carousel *car, struct DownloadInfoIndication *dii, uint32_t transactionId)
{
    unsigned int nmodules;
    unsigned int i;
    int processed = 0;

    verbose("DownloadInfoIndication ");
    verbose("transactionId: %u, ", transactionId);
    verbose("downloadId: %u, ", ntohl(dii->downloadId));

    nmodules = DII_numberOfModules(dii);
    // verbose2("numberOfModules: %u, ", nmodules);

    for(i=0; i<nmodules; i++)
    {
        struct DIIModule *mod;
        mod = DII_module(dii, i);
        vverbose("Module %u", i);
        vverbose(" moduleId: %u", ntohs(mod->moduleId));
        vverbose(" moduleVersion: %u", mod->moduleVersion);
        vverbose(" moduleSize: %u", ntohl(mod->moduleSize));
        if(find_module(car, ntohs(mod->moduleId), mod->moduleVersion, ntohl(dii->downloadId)) == NULL) {
            vverbose("Adding module %u", i);
            add_module(car, dii, mod);
            processed = 1;
        }
    }


    return processed;
}
Beispiel #2
0
/* Hash test: buffer of size byte. Run test n times. */
static void run_test(size_t size, unsigned int n, unsigned int l)
{
	uint64_t t;
	struct statistics stats;
	TEEC_Operation op;
	int n0 = n;

	alloc_shm(size, algo);

	if (!random_in)
		memset((uint8_t *)in_shm.buffer + offset, 0, size);

	memset(&op, 0, sizeof(op));
	op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_PARTIAL_INPUT,
					 TEEC_MEMREF_PARTIAL_OUTPUT,
					 TEEC_VALUE_INPUT, TEEC_NONE);
	op.params[0].memref.parent = &in_shm;
	op.params[0].memref.offset = 0;
	op.params[0].memref.size = size + offset;
	op.params[1].memref.parent = &out_shm;
	op.params[1].memref.offset = 0;
	op.params[1].memref.size = hash_size(algo);
	op.params[2].value.a = l;
	op.params[2].value.b = offset;

	verbose("Starting test: %s, size=%zu bytes, ",
		algo_str(algo), size);
	verbose("random=%s, ", yesno(random_in));
	verbose("unaligned=%s, ", yesno(offset));
	verbose("inner loops=%u, loops=%u, warm-up=%u s\n", l, n, warmup);

	if (warmup)
		do_warmup();

	memset(&stats, 0, sizeof(stats));
	while (n-- > 0) {
		t = run_test_once((uint8_t *)in_shm.buffer + offset, size, &op, l);
		update_stats(&stats, t);
		if (n % (n0/10) == 0)
			vverbose("#");
	}
	vverbose("\n");
	printf("min=%gμs max=%gμs mean=%gμs stddev=%gμs (%gMiB/s)\n",
	       stats.min/1000, stats.max/1000, stats.m/1000,
	       stddev(&stats)/1000, mb_per_sec(size, stats.m));
	free_shm();
}
Beispiel #3
0
//---------------------------------------------------------------------------
// Read from xml
//---------------------------------------------------------------------------
bool VisusBorderAxis::fromXML(XMLNode& node)
{
  if (strcmp(XML_TAG, node.getName())) 
  {
    std::stringstream ss;
    ss << "VisusBorderAxis did not receive its top level node. received (" << node.getName() << ")\n";
    vwarning(ss.str().c_str());
    vverbose(ss.str().c_str(), VISUS_XML_VERBOSE);
    return false;
  }

  XMLNode child = node.getChildNode("label");
  XMLNode text  = child.getChildNode(0);
  if (! mLabel.fromXML(text)) {
    vwarning("Failed to retrieve label text for VisusBorderAxis");
    return false;
  }

  mDrawLabels = xmltobool(node.getAttribute("drawLabel"), mDrawLabels);
  mLabelPosition = (AXISSide) xmltoi(node.getAttribute("labelPosition"), mLabelPosition);
  mLabelAlignment = (AXISAlignment) xmltoi(node.getAttribute("labelAlignment"), mLabelAlignment);
  mLabelOffset = xmltof(node.getAttribute("labelOffset"), mLabelOffset);

  child = node.getChildNode("legend");
  text  = child.getChildNode(0);
  if (! mLegend.fromXML(text)) {
    vwarning("Failed to retrieve label text for VisusBorderAxis");
    return false;
  }

  mDrawLegend = xmltobool(node.getAttribute("drawLegend"), mDrawLegend);
  mLegendPosition = (AXISSide) xmltoi(node.getAttribute("legendPosition"), mLegendPosition);
  mLegendAlignment= (AXISAlignment) xmltoi(node.getAttribute("legendAlignment"), mLegendAlignment);
  mLegendOffset = xmltof(node.getAttribute("legendOffset"), mLegendOffset);

  mDrawTicks = xmltobool(node.getAttribute("drawTicks"), mDrawTicks);
  mMajorTickLength = xmltof(node.getAttribute("majorTickLength"), mMajorTickLength);
  mMajorTickThickness = xmltof(node.getAttribute("majorTickThickness"), mMajorTickThickness);
  mMinorTickLength = xmltof(node.getAttribute("minorTickLength"), mMinorTickLength);
  mMinorTickThickness = xmltof(node.getAttribute("minorTickThickness"), mMinorTickThickness);
  mTickPosition = (AXISSide) xmltoi(node.getAttribute("tickPosition"), mTickPosition);

  mMinValue = xmltof(node.getAttribute("min"), mMinValue);
  mMaxValue = xmltof(node.getAttribute("max"), mMaxValue);
 
  mMajorTicks = xmltoi(node.getAttribute("majorTicks"), mMajorTicks);
  mMinorTicks = xmltoi(node.getAttribute("minorTicks"), mMinorTicks);
 
  XMLNode tickColor = node.getChildNode("TickColor");
  XMLNode color = tickColor.getChildNode(0);
  if (! mTickColor.fromXML(color)) {
    vwarning("Failed to retrieve tick color for VisusBorderAxis");
    return false;
  }

  return true;
}
Beispiel #4
0
bool
read_pmt(char *demux, uint16_t service_id, unsigned int timeout, unsigned char *out)
{
	char cache_item[PATH_MAX];
	unsigned char pat[MAX_TABLE_LEN];
	uint16_t section_length;
	uint16_t offset;
	uint16_t map_pid = 0;
	bool found;
	bool rc;

	/* is it in the cache */
	snprintf(cache_item, sizeof(cache_item), "pmt-%u", service_id);
	if(cache_load(cache_item, out))
		return true;

	/* get the PAT */
	if(!read_pat(demux, timeout, pat))
		return false;

	section_length = 3 + (((pat[1] & 0x0f) << 8) + pat[2]);

	/* find the PMT for this service_id */
	found = false;
	offset = 8;
	/* -4 for the CRC at the end */
	while((offset < (section_length - 4)) && !found)
	{
		if((pat[offset] << 8) + pat[offset+1] == service_id)
		{
			map_pid = ((pat[offset+2] & 0x1f) << 8) + pat[offset+3];
			found = true;
		}
		else
		{
			offset += 4;
		}
	}

	if(!found)
		fatal("Unable to find PMT PID for service_id %u", service_id);

	vverbose("PMT PID: %u", map_pid);

	/* get the PMT */
	rc = read_table(demux, map_pid, TID_PMT, timeout, out, 0);

	/* cache it */
	if(rc)
		cache_save(cache_item, out);
	else
		error("Unable to read PMT");

	return rc;
}
Beispiel #5
0
VisusRenderer::VisusRenderer(const int width, const int height):
  mWidth(width), mHeight(height), mSize(width*height), mValid(false)
{	
  mPerPixel = 3;	
	
  // Create Storage For Image
  mImage = new unsigned char[mSize*mPerPixel];
  for (int i=0; i<mSize; ++i) {
	  mImage[i] = 0;
  }
  vverbose("VisusRenderer::ctor:  Width(%d) Height(%d)\n", 500, mWidth, mHeight);

  init();
}
Beispiel #6
0
int
process_ddb(char* paramDir, struct carousel *car, struct DownloadDataBlock *ddb, uint32_t downloadId, uint32_t blockLength)
{
    unsigned char *block;
    struct module *mod;
    int processed = 0;

    verbose("DownloadDataBlock ");
    vverbose("downloadId: %u", downloadId);
    verbose("moduleId: %u", ntohs(ddb->moduleId));
    vverbose("moduleVersion: %u", ddb->moduleVersion);
    verbose("blockNumber: %u", ntohs(ddb->blockNumber));
    vverbose("blockLength: %u", blockLength);

    block = DDB_blockDataByte(ddb);
    vhexdump(block, blockLength);

    if((mod = find_module(car, ntohs(ddb->moduleId), ddb->moduleVersion, downloadId)) != NULL) {
        download_block(paramDir, car, mod, ntohs(ddb->blockNumber), block, blockLength);
        processed = 1;
    }

    return processed;
}
Beispiel #7
0
char *
zap_name(unsigned int adapter, unsigned int frontend)
{
	char fe_dev[PATH_MAX];
	int fe_fd;
	struct dvb_frontend_info fe_info;
	bool got_info;

	/* see what type of DVB device the adapter is */
	snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter, frontend);

	if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
		fatal("open '%s': %s", fe_dev, strerror(errno));

	vverbose("Getting frontend info");

	do
	{
		/* maybe interrupted by a signal */
		got_info = (ioctl(fe_fd, FE_GET_INFO, &fe_info) >= 0);
		if(!got_info && errno != EINTR)
			fatal("ioctl FE_GET_INFO: %s", strerror(errno));
	}
	while(!got_info);

	close(fe_fd);

	if(fe_info.type == FE_OFDM)
	{
		vverbose("Adapter %u is a '%s' DVB-T card", adapter, fe_info.name);
		return "tzap";
	}
	else if(fe_info.type == FE_QPSK)
	{
		vverbose("Adapter %u is a '%s' DVB-S card", adapter, fe_info.name);
		return "szap";
	}
	else if(fe_info.type == FE_QAM)
	{
		vverbose("Adapter %u is a '%s' DVB-C card", adapter, fe_info.name);
		return "czap";
	}
	else if(fe_info.type == FE_ATSC)
	{
		vverbose("Adapter %u is a '%s' ATSC card", adapter, fe_info.name);
		return "azap";
	}
	else
	{
		vverbose("Adapter %u (%s); unknown card type %d", adapter, fe_info.name, fe_info.type);
		return "";
	}
}
int VisusAxisAlignedExtractor::produce()
{  
  VisusDataDescription dataset; 
  VisusFieldIndex field_index; 
  VisusGlobalTime current_time;
  VisusDataRequest request;     
  VisusDataSource *old_source;
  VisusBoundingBox query_region;
  VisusBoundingBox bbox;
  std::vector<double> left_lower; // Left lower corner of the domain bounding box
  std::vector<double> right_upper; // Right upper corner o fthe domain bounding box
  VisusUnit unit; // The physical unit of the domain


  //fprintf(stderr,"VisusAxisAlignedExtractor::produce()\n");

  // flag to indicate whether we should produce at all
  bool must_produce = false;

  /* The following code is very similar to the code in the
   * extractinLoop except that the variables are used slighlty
   * differently. In the extraction loop the local variables in the
   * loop store the information of the previous extraction and the
   * member variables are used to synchronize with the shared
   * values. Here the opposite strategy is used. The member variables
   * store the last request data etc. while the local variables are
   * updated from the shared values.
   */


  // Access the dataset, data request, and field index currently
  // stored in our parameter list
  getValue(dataset);
  getValue(request);
  getValue(field_index);
  getValue(current_time);
  
  // If the dataset has changed
  if (mDataDescription != dataset) {
    mDataDescription = dataset;
    
    // store the out-dated data source
    old_source = mDataSource;
    
    // Create a new appropriate data source
    mDataSource = VisusDataSourceFactory::make(dataset); 
    
    // Store the data source specific domain attribute
    unit = mDataSource->unit();
    
    // Get the new domain box
    mDataSource->domainBoundingBox(bbox);
    
    // And make sure that our bouding box is up to date
    this->setValue(bbox);
    
    // Get the new time parameters
    mCurrentTime = mDataSource->timeInfo();
    
    // And update the shared parameter accordingly
    setValue(mCurrentTime);
    
    // Delete the now obsolete data source
    delete old_source;
    
    // indicate that we have to produce new data
    must_produce = true;
  }
  
  // If the current data source for some reason is not valid
  if (!mDataSource->isValid()) {
    
    vmessage("Data source not valid cannot produce.\nDataDescriptor:\n%s\n",dataset.c_str());
    
    // We cannot do anything
    return 0;
  }

  // If we have a valid data source we want to make sure that the
  // request reflects the current bounding box.
  mRequest.domainBBox(bbox);
  setValue(mRequest);

  
  
  // Store the data source specific domain attribute
  unit = mDataSource->unit();
  mDataSource->domainBoundingBox(left_lower,right_upper);

  // If the scalar function has changed
  if (mFieldIndex != field_index) {
    mFieldIndex = field_index;
    must_produce = true;
  }
  
  // If the field index is out of range
  if ((field_index < 0) || (field_index >= mDataSource->numberOfFields())) {
    
    vmessage("Field index %d out of range for this data set, cannot extract data",(int)field_index);
    
    return 0;
  }

  /* 
  // See above for comments
  // If the field index is out of range
  if ((current_time < mDataSource->timeBegin()) || 
      (current_time > mDataSource->timeEnd()))
  {
    vwarning("Current time out of range for this data set, cannot extract data");
    return 0;
  }
  */

  // If current time has changed
  if (mCurrentTime != current_time) {
    mCurrentTime = current_time;
    must_produce = true;
    vverbose("VisusAxisAlignedExtractor - Time has changed!\n", VISUS_TIME_VERBOSE);
  }  
  
  // If we have gotten a new request
  if (mRequest != request) {
    mRequest = request;
    must_produce = true;
  }
  
  // If the current request is not valid
  if (!request.valid()) {      
    vwarning("DataRequest invalid cannot extract data");
    
    return 0;
  }
  
  
  if (must_produce) {

    // Copy the data source dependent information into mData. Note
    // that even though this information only changes when a new data
    // source is opened the copy here is necessary. Currently, some
    // data is passed on by swapping in which case the current unit
    // and domain bounding box might be invalid for the new data we
    // want to extract. Maybe for performance reasons this should be
    // changed later.
    mData.unit(unit);
    //mData.setDomainBoundingBox(left_lower,right_upper);

    // First we determined the actual bounding box of the query region
    // Since this is an axis-aligned extractor we assume that the
    // transformed extent is still axis aligned. Otherwise, we will
    // inflate the bbox.
    query_region = request.queryRegion();
    
    // Access the data
    if (mDataSource->accessAlignedData(query_region.leftLower(),query_region.rightUpper(),
                                       request.startStrides(),request.endStrides(),request.endStrides(),
                                       field_index, current_time.time(),
                                       mData, this->mProductLock) != 0) {
      
      // If the data access was successful then we have extracted a
      // valid piece of data and the mProductLock is *locked*

      // If the data is supposed to be lower dimensional we
      // potentially have to compact the dimensions and adjust the
      // matrices
      if (request.requestType() == VISUS_1D_REQUEST)
        mData.compactDimensions(1);
      else if (request.requestType() == VISUS_2D_REQUEST)
        mData.compactDimensions(2);

      if (this->mProductLock.unlock() == 0)
        vwarning("Could not unlock data after loading new data.");
      
    }
    else {
      vwarning("Data access failed could not extract data.");
      
      return 0;
    }
  }
  
  return 1;
}
void* VisusAxisAlignedExtractor::extractionLoop(void *)
{
  VisusDataDescription dataset; // The name of the data set we are
                                // working on
  VisusFieldIndex field_index;  // The index of the current field we
                                // are extracting
  VisusGlobalTime current_time; // The time of field we are extracting
  VisusDataRequest request;     // The current request

  VisusDataSource *old_source;
  int stride_index;
  std::vector<int> strides(3); 
  std::vector<double> extent(3);
  VisusBoundingBox bbox; // The domain bounding box of the data
  VisusUnit unit; // The physical unit of the domain
  VisusBoundingBox query_region;

  // Make sure the constructor of the thread is finished
  while (mThread == NULL) 
    sleepmillisec(sUpdateInterval);
    
  // Indicate that we have started processing
  mThread->status(WORKING);

  // Until we get an outside signal to stop we continue
  while (!mThread->terminated()) {

    ////////////////////////////////////////////////////////////
    //////      Stage 1: Request Synchronization      //////////
    ////////////////////////////////////////////////////////////

    // Access the dataset, data request, and field index currently
    // stored in our parameter list
    getValue(mDataDescription);
    getValue(mRequest);
    getValue(mFieldIndex);
    getValue(mCurrentTime);

    // If the dataset has changed
    if (mDataDescription != dataset) {
      dataset = mDataDescription;

      // store the out-dated data source
      old_source = mDataSource;
      
      // Indicate that we have not worked on this data at all
      stride_index = -1;

      // Create a new appropriate data source
      mDataSource = VisusDataSourceFactory::make(dataset); 
      
      //sleepmillisec(100);
      //fprintf(stderr,"Continue exraction\n");

      // Store the data source specific domain attribute
      unit = mDataSource->unit();

      // Get the new domain box
      mDataSource->domainBoundingBox(bbox);

      // And make sure that our bouding box is up to date
      this->setValue(bbox);

      // Get the new time parameters
      mCurrentTime = mDataSource->timeInfo();

      // And update the shared parameter accordingly
      setValue(mCurrentTime);
        
      // Delete the now obsolete data source
      delete old_source;

    }

    // If the current data source for some reason is not valid
    if (!mDataSource->isValid()) {
      // Indicate that we cannot work on anything
      mStatus = VISUS_EXTRACTION_INVALID;

      // Make clear that we have just verified our status
      mSynchronizationFlag = false;
      
      vmessage("Data source not valid extraction will hold.\nDataDescriptor:\n%s\n",dataset.c_str());
      
      // Wait till hopefully new valid values come it
      sleepmillisec(sUpdateInterval);
      
      // and start over
      continue; 
    }

    // If we have a valid data source we want to make sure that the
    // request reflects the current bounding box.
    mRequest.domainBBox(bbox);

    // Copy the data source dependent information into mData. Note
    // that even though this information only changes when a new data
    // source is opened the copy here is necessary. Currently, some
    // data is passed on by swapping in which case the current unit
    // and domain bounding box might be invalid for the new data we
    // want to extract. Maybe for performance reasons this should be
    // changed later.
    mData.unit(unit);
    

    // If the scalar function has changed
    if (mFieldIndex != field_index) {
      field_index = mFieldIndex;
      stride_index = -1;
    }

    // If the field index is out of range
    if ((field_index < 0) || (field_index >= mDataSource->numberOfFields())) {
      // Indicate that we cannot work on anything
      mStatus = VISUS_EXTRACTION_INVALID;

      // Make clear that we have just verified our status
      mSynchronizationFlag = false;
      
      vmessage("Field index %d out of range for this data set, cannot extract data",(int)field_index);

      // Wait till hopefully new valid values come it
      sleepmillisec(sUpdateInterval);
      
      // and start over
      continue; 
    }
    
    // If the current time requested has changed
    if (mCurrentTime != current_time) {
 
      current_time = mCurrentTime;
      vverbose("VisusAxisAlignedExtractor - Time has changed!\n", VISUS_TIME_VERBOSE);

      // Indicate that we have not worked on this data at all
      stride_index = -1; 
    }

    /*
    // In the new implementation of VisusGlobalTime and the data
    // source the data source will automatically clamp any illegal
    // value to the closest valid one. Thus this test is no longer
    // necessary. However, this might trigger a "busy" wait if the
    // extractor continuously feeds incorrect data to the data
    // source. If this ever becomes an issue (it shouldn't since the
    // global shared time should reflect the data souce time) this
    // code needs to be re-activated. (ptb 03/05/09)

    // If the field index is out of range
    if ((current_time < mDataSource->timeBegin()) || 
        (current_time > mDataSource->timeEnd())) {
    
      vwarning("Current time %s out of range for this data set, cannot extract data",current_time.time().toString().c_str());

      // Indicate that we cannot work on anything
      mStatus = VISUS_EXTRACTION_INVALID;

      // Make clear that we have just verified our status
      mSynchronizationFlag = false;
      
      // Wait till hopefully new valid values come it
      sleepmillisec(sUpdateInterval);
      
      // and start over
      continue; 
    }
    */

    // If we have gotten a new request
    if (mRequest != request) {
      request = mRequest;
      setValue(mRequest);
      stride_index = -1;
    }

    // If the current request is not valid
    if (!request.valid()) {
      mStatus = VISUS_EXTRACTION_INVALID;

      // Make clear that we have just verified our status
      mSynchronizationFlag = false;
      
      vwarning("DataRequest invalid cannot extract data");
      sleepmillisec(sUpdateInterval);
      
      continue; 
    }
    
    ////////////////////////////////////////////////////////////
    //////      Stage 2: Resolution Refinement        //////////
    ////////////////////////////////////////////////////////////

    // If we have already worked on the finest resolution requested
    if (stride_index == request.numberOfResolutions()-1) {
      // Indicate that we are done with the last request
      mStatus = VISUS_EXTRACTION_FINISHED;
 
      // Make clear that we have just verified our status
      mSynchronizationFlag = false;
      
      sleepmillisec(sUpdateInterval);
      continue; 
    }

    // Increase our target resolution
    stride_index++;

    // Set our status depending on whether we are starting or refining
    // this request
    if (stride_index == 0) 
      mStatus = VISUS_EXTRACTION_STARTED;
    else 
      mStatus = VISUS_EXTRACTION_REFINING;
      
    // Make clear that we just verified our status
    mSynchronizationFlag = false;
    
    strides = request.strides(stride_index);
    
    ////////////////////////////////////////////////////////////
    //////      Stage 4: Extracting Data              //////////
    ////////////////////////////////////////////////////////////

    // First we determined the actual bounding box of the query region
    // Since this is an axis-aligned extractor we assume that the
    // transformed extent is still axis aligned. Otherwise, we will
    // inflate the bbox.
    query_region = request.queryRegion();

    /*
    fprintf(stderr,"VisusAxisAlignedExtractor::extractionLoop   accessing Data\n");
    fprintf(stderr,"[%f,%f,%f] x [%f,%f,%f] at strides <%d,%d,%d>\n\n",
            query_region.leftLower()[0],query_region.leftLower()[1],query_region.leftLower()[2],
            query_region.rightUpper()[0],query_region.rightUpper()[1],query_region.rightUpper()[2],
            strides[0],strides[1],strides[2]);
    */
    
    // Access the data
    if (mDataSource->accessAlignedData(query_region.leftLower(),query_region.rightUpper(),
                                       request.startStrides(),request.endStrides(),strides,
                                       field_index, current_time.time(),
                                       mData, this->mProductLock) != 0) {
      
      // If the data access was successful then we have extracted a
      // valid piece of data and the mProductLock is *locked*

      // If the data is supposed to be lower dimensional we
      // potentially have to compact the dimensions and adjust the
      // matrices
      if (request.requestType() == VISUS_1D_REQUEST)
        mData.compactDimensions(1);
      else if (request.requestType() == VISUS_2D_REQUEST)
        mData.compactDimensions(2);

      if (this->mProductLock.unlock() == 0)
        vwarning("Could not unlock data after loading new data.");
   
      this->markAsDirty();
    }
  }

 
  mThread->status(FINISHED);  

  return NULL;
}
Beispiel #10
0
int main(int argc, char *argv[])
{
	int i;
	struct timespec ts;

	/* Parse command line */
	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-h")) {
			usage(argv[0]);
			return 0;
		}
	}
	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-l")) {
			NEXT_ARG(i);
			l = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-a")) {
			NEXT_ARG(i);
			if (!strcasecmp(argv[i], "SHA1"))
				algo = TA_SHA_SHA1;
			else if (!strcasecmp(argv[i], "SHA224"))
				algo = TA_SHA_SHA224;
			else if (!strcasecmp(argv[i], "SHA256"))
				algo = TA_SHA_SHA256;
			else if (!strcasecmp(argv[i], "SHA384"))
				algo = TA_SHA_SHA384;
			else if (!strcasecmp(argv[i], "SHA512"))
				algo = TA_SHA_SHA512;
			else {
				fprintf(stderr, "%s, invalid algorithm\n",
					argv[0]);
				usage(argv[0]);
				return 1;
			}
		} else if (!strcmp(argv[i], "-n")) {
			NEXT_ARG(i);
			n = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-r")) {
			random_in = 1;
		} else if (!strcmp(argv[i], "-s")) {
			NEXT_ARG(i);
			size = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-u")) {
			offset = 1;
		} else if (!strcmp(argv[i], "-v")) {
			verbosity++;
		} else if (!strcmp(argv[i], "-w")) {
			NEXT_ARG(i);
			warmup = atoi(argv[i]);
		} else {
			fprintf(stderr, "%s: invalid argument: %s\n",
				argv[0], argv[i]);
			usage(argv[0]);
			return 1;
		}
	}

	vverbose("sha-perf version %s\n", TO_STR(VERSION));
	if (clock_getres(CLOCK_MONOTONIC, &ts) < 0) {
		perror("clock_getres");
		return 1;
	}
	vverbose("Clock resolution is %lu ns\n", ts.tv_sec*1000000000 +
		ts.tv_nsec);

	open_ta();
	prepare_op();
	run_test(size, n, l);

	return 0;
}
Beispiel #11
0
bool
tune_service_id(unsigned int adapter, unsigned int frontend, unsigned int timeout, uint16_t service_id, int* tuner_fd)
{
	char fe_dev[PATH_MAX];
	bool got_info;
	struct dvb_frontend_info fe_info;
	struct dvb_frontend_parameters current_params;
	struct dvb_frontend_parameters needed_params;
	char polarity;
	unsigned int sat_no;
	bool hi_lo;
	struct dvb_frontend_event event;
//	fe_status_t status;
	bool lock;
	/* need to keep the frontend device open to stop it untuning itself */
	static int fe_fd = -1;
	static bool first_time = true;
  
  #if 0
  if (*tuner_fd = -1)
  {
    fe_fd = -1;
    bool first_time = true;
  }
  #endif

	if(fe_fd < 0)
	{
		snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter, frontend);
		/*
		 * need O_RDWR if you want to tune, O_RDONLY is okay for getting info
		 * if someone else is using the frontend, we can only open O_RDONLY
		 * => we can still download data, but just not retune
		 */
		if((fe_fd = open(fe_dev, O_RDWR | O_NONBLOCK)) < 0)
		{
			error("Unable to open '%s' read/write; you will not be able to retune", fe_dev);
			if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
				fatal("open '%s': %s", fe_dev, strerror(errno));
			/* don't try to tune in */
			first_time = false;
		}
	}

	vverbose("Getting frontend info");

	do
	{
		/* maybe interrupted by a signal */
		got_info = (ioctl(fe_fd, FE_GET_INFO, &fe_info) >= 0);
		if(!got_info && errno != EINTR)
			fatal("ioctl FE_GET_INFO: %s", strerror(errno));
	}
	while(!got_info);

	/* see what we are currently tuned to */
	if(ioctl(fe_fd, FE_GET_FRONTEND, &current_params) < 0)
		fatal("ioctl FE_GET_FRONTEND: %s", strerror(errno));

	/* find the tuning params for the service */
	if(!get_tune_params(fe_info.type, service_id, &needed_params, &polarity, &sat_no))
	{
		error("service_id %u not found in channels.conf file", service_id);
		return false;
	}

	/*
	 * if no-one was using the frontend when we open it
	 * FE_GET_FRONTEND may say we are tuned to the frequency we want
	 * but when we try to read any data, it fails
	 * checking if we have a lock doesn't seem to work
	 * so, always retune the first time we are called
	 */
#if 0
	if(ioctl(fe_fd, FE_READ_STATUS, &status) < 0)
		lock = false;
	else
		lock = status & FE_HAS_LOCK;
#endif

	/* are we already tuned to the right frequency */
	vverbose("Current frequency %u; needed %u; first_time=%d", current_params.frequency, needed_params.frequency, first_time);

	/* frequency resolution is up to 1 kHz */
	if(first_time
	|| abs(current_params.frequency - needed_params.frequency) >= ONE_kHz)
	{
		first_time = false;
		verbose("Retuning to frequency %u", needed_params.frequency);
		/* empty event queue */
		while(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
			; /* do nothing */
		/* do DISEQC (whatever that is) for DVB-S */
		if(fe_info.type == FE_QPSK)
		{
			if(needed_params.frequency < SLOF)
			{
				needed_params.frequency -= LOF1;
				hi_lo = false;
			}
			else
			{
				needed_params.frequency -= LOF2;
				hi_lo = true;
			}
			if(do_diseqc(fe_fd, sat_no, polarity, hi_lo) < 0)
				error("DISEQC command failed for service_id %u", service_id);
		}
		/* tune in */
		if(ioctl(fe_fd, FE_SET_FRONTEND, &needed_params) < 0)
			fatal("Unable to retune: ioctl FE_SET_FRONTEND: %s", strerror(errno));
		/* wait for lock */
		vverbose("Waiting for tuner to lock on");
		/* TODO: use timeout value here */
    struct timeval start, end;
    gettimeofday(&start, NULL);
		lock = false;
		while(!lock)
		{
			if(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
				lock = event.status & FE_HAS_LOCK;
      gettimeofday(&end, NULL);
      if (end.tv_sec  - start.tv_sec > 120)
        return false;
		}
		vverbose("Retuned");
	}

	*tuner_fd = fe_fd;
  return true;
}
void InputThread::verbose(_In_z_ _Printf_format_string_ TCHAR const * const format, ...) {
  va_list argptr;
  va_start(argptr, format);
  vverbose(format, argptr);
  va_end(argptr);
}
Beispiel #13
0
VisusSmartPointer<VisusGroup> VisusFactory::createNode(VisusNodeType nodeType)
{
  switch (nodeType)
  {
  case VISUS_GROUP_NODE:
    vverbose("creating group node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusGroup>();

  case VISUS_SCENE_NODE:
    vverbose("creating scene node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusSceneNode>();

  case VISUS_ALIGNED_EXTRACTOR:
    vverbose("creating aligned extractor node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusAxisAlignedExtractor>();

  case VISUS_ORTHO_SLICE:
    vverbose("creating orthogonal slice\n", VISUS_XML_VERBOSE);
    return constructNode<VisusOrthogonalSlice>();

  case VISUS_TEXT_NODE:
    vverbose("creating text node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusTextNode>();

  case VISUS_SPHERE_NODE:
    vverbose("creating sphere node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusSphereNode>();

  case VISUS_COLOR_BAR:
    vverbose("creating color bar\n", VISUS_XML_VERBOSE);
    return constructNode<VisusColorBar>();

  case VISUS_TICK_MARKS:
    vverbose("creating tick marks\n", VISUS_XML_VERBOSE);
    return constructNode<VisusTickMarks>();

  case VISUS_ISOSURFACE:
    vverbose("creating isosurface\n", VISUS_XML_VERBOSE);
    return constructNode<VisusIsoSurface>();

  case VISUS_DATA_PROBE:
    vverbose("creating data probe\n", VISUS_XML_VERBOSE);
    return constructNode<VisusDataProbe>();

  case VISUS_SHAPES_NODE:
    vverbose("creating shapes\n", VISUS_XML_VERBOSE);
    return constructNode<VisusShapesNode>();

  case VISUS_MESH_NODE:
    vverbose("creating mesh node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusMeshDisplay>();

  case VISUS_LABEL_NODE:
    vverbose("creating label node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusLabelNode>();

  case VISUS_TEXTURE_VIEWER:
    vverbose("creating texture viewer\n", VISUS_XML_VERBOSE);
    return constructNode<VisusTextureViewer>();

  case VISUS_EARTH_NODE:
    vverbose("creating earth node\n", VISUS_XML_VERBOSE);
    return constructNode<VisusEarthNode>();

  case VISUS_SPHERE_SLICE:
    vverbose("creating sphere slice\n", VISUS_XML_VERBOSE);
    return constructNode<VisusSphereSlice>();

  case VISUS_LINE_GRAPH:
    vverbose("creating line graph\n", VISUS_XML_VERBOSE);
    return constructNode<VisusLineGraph>();

  case VISUS_HISTOGRAM:
    vverbose("creating histogram\n", VISUS_XML_VERBOSE);
    return constructNode<VisusHistogram>();

  case VISUS_COLORED_ISOSURFACE:
    vverbose("creating colored isosurface\n", VISUS_XML_VERBOSE);
    return constructNode<VisusColoredIsoSurface>();

  case VISUS_HEIGHT_FIELD:
    vverbose("creating height field\n", VISUS_XML_VERBOSE);
    return constructNode<VisusHeightField>();

  default:
    {
      std::stringstream ss;
      ss << "unknown type (" << nodeType << "). VisusFactory does not know how to create";
      vwarning(ss.str().c_str());
    }
  }
  return pVisusGroup();
}