Esempio n. 1
0
/**************************************************************************************
** Main device loop. We check for capture progress here
***************************************************************************************/
void RadioSim::TimerHit()
{
	long timeleft;

	if (isConnected() == false)
		return; //  No need to reset timer if we are not connected anymore

	if (InCapture)
	{
		timeleft = CalcTimeLeft();
		if(timeleft < 0.1)
		{
			/* We're done capturing */
			LOG_INFO("Capture done, downloading data...");
			grabData();
			InCapture = false;
			timeleft = 0.0;
		}

		// This is an over simplified timing method, check DetectorSimulator and rtlsdrDetector for better timing checks
		PrimaryDetector.setCaptureLeft(timeleft);
	}
	double value = (DetectorCoordsN[0].value + (360.0 / SIDEREAL_DAY) * POLLMS / 1000.0);
	if (value >= FOV_DEG)
		value -= FOV_DEG;
	Ra = value;
	DetectorCoordsN[0].value = Ra;
	IDSetNumber(&DetectorCoordsNP, nullptr);
	SetTimer(POLLMS);
	return;
}
void btGpuDemoDynamicsWorld::solveConstraintsCPU2(btContactSolverInfo& solverInfo)
{
	BT_PROFILE("solveConstraints");
	grabData();
	createBatches2();
	btCudaPartProps partProps;
	{
		BT_PROFILE("set constraint data CPU");
		
		partProps.m_mass = 1.0f;
		partProps.m_diameter = m_objRad * 2.0f;
		partProps.m_restCoeff = 1.0f;

		btGpu_clearAccumulationOfLambdaDt(m_hLambdaDtBox, m_totalNumConstraints, m_maxVtxPerObj * 2);

		if(!m_useBulletNarrowphase)
		{
			btGpu_setConstraintData(m_hIds, m_totalNumConstraints - m_numNonContactConstraints, m_numObj + 1, m_hPos, m_hRot,m_hShapeBuffer, m_hShapeIds,
									partProps,	m_hContact);
		}
	}

	btCudaBoxProps boxProps;
	boxProps.minX = m_worldMin[0];
	boxProps.maxX = m_worldMax[0];
	boxProps.minY = m_worldMin[1];
	boxProps.maxY = m_worldMax[1];
	
	{
		BT_PROFILE("btCuda_collisionBatchResolutionBox CPU");
		
		int nIter=getSolverInfo().m_numIterations;
		btDispatcherInfo& dispatchInfo = getDispatchInfo();
		btScalar timeStep = dispatchInfo.m_timeStep;

		for(int i=0;i<nIter;i++){
			btGpu_collisionWithWallBox(m_hPos, m_hVel, m_hRot, m_hAngVel,m_hShapeBuffer, m_hShapeIds,
				m_hInvMass, partProps, boxProps, m_numObj + 1, timeStep);
			int* pBatchIds = m_hBatchIds;
			for(int iBatch=0;iBatch < m_maxBatches;iBatch++)
			{
				int numContConstraints = m_numInBatches[iBatch]; 
				if(!numContConstraints)
				{
					break;
				}
				btGpu_collisionBatchResolutionBox( m_hIds, pBatchIds, numContConstraints, m_numObj + 1,
													m_hPos, m_hVel,
													m_hRot, m_hAngVel,
													m_hLambdaDtBox,
													m_hContact,
													m_hInvMass,
													partProps, iBatch, timeStep);
				pBatchIds += numContConstraints;
			}
		}
	}
	writebackData();
	m_numSimStep++;
} 
Esempio n. 3
0
static int intAddEntry(Header h, rpmtd td)
{
    indexEntry entry;
    rpm_data_t data;
    int length;

    /* Count must always be >= 1 for headerAddEntry. */
    if (td->count <= 0)
	return 0;

    if (hdrchkType(td->type))
	return 0;
    if (hdrchkData(td->count))
	return 0;

    length = 0;
    data = grabData(td->type, td->data, td->count, &length);
    if (data == NULL || length <= 0)
	return 0;

    /* Allocate more index space if necessary */
    if (h->indexUsed == h->indexAlloced) {
	h->indexAlloced += INDEX_MALLOC_SIZE;
	h->index = xrealloc(h->index, h->indexAlloced * sizeof(*h->index));
    }

    /* Fill in the index */
    entry = h->index + h->indexUsed;
    entry->info.tag = td->tag;
    entry->info.type = td->type;
    entry->info.count = td->count;
    entry->info.offset = 0;
    entry->data = data;
    entry->length = length;

    if (h->indexUsed > 0 && td->tag < h->index[h->indexUsed-1].info.tag)
	h->flags &= ~HEADERFLAG_SORTED;
    h->indexUsed++;

    return 1;
}
Esempio n. 4
0
int headerMod(Header h, rpmtd td)
{
    indexEntry entry;
    rpm_data_t oldData;
    rpm_data_t data;
    int length;

    /* First find the tag */
    entry = findEntry(h, td->tag, td->type);
    if (!entry)
	return 0;

    length = 0;
    data = grabData(td->type, td->data, td->count, &length);
    if (data == NULL || length <= 0)
	return 0;

    /* make sure entry points to the first occurence of this tag */
    while (entry > h->index && (entry - 1)->info.tag == td->tag)  
	entry--;

    /* free after we've grabbed the new data in case the two are intertwined;
       that's a bad idea but at least we won't break */
    oldData = entry->data;

    entry->info.count = td->count;
    entry->info.type = td->type;
    entry->data = data;
    entry->length = length;

    if (ENTRY_IN_REGION(entry)) {
	entry->info.offset = 0;
    } else
	oldData = _free(oldData);

    return 1;
}
Esempio n. 5
0
/**************************************************************************************
** Main device loop. We check for capture progress here
***************************************************************************************/
void RadioSim::TimerHit()
{
    long timeleft;

    if (isConnected() == false)
        return; //  No need to reset timer if we are not connected anymore

    if (InCapture)
    {
        timeleft = CalcTimeLeft();
        if(timeleft < 0.1)
        {
            /* We're done capturing */
            LOG_INFO("Capture done, downloading data...");
            timeleft = 0.0;
            grabData();
        }

        // This is an over simplified timing method, check DetectorSimulator and rtlsdrDetector for better timing checks
        PrimaryDetector.setCaptureLeft(timeleft);
    }
    SetTimer(POLLMS);
    return;
}
void btGpuDemoDynamicsWorld::solveConstraints2(btContactSolverInfo& solverInfo)
{
//#ifdef BT_USE_CUDA
#if 1
	BT_PROFILE("solveConstraints");
	grabData();
	createBatches2();
	copyDataToGPU();

	btCudaPartProps partProps;
	setConstraintData(partProps);

	btCudaBoxProps boxProps;
	boxProps.minX = m_worldMin[0];
	boxProps.maxX = m_worldMax[0];
	boxProps.minY = m_worldMin[1];
	boxProps.maxY = m_worldMax[1];
	btVector3 hParams[2];
	hParams[0] = m_worldMin;
	hParams[1] = m_worldMax;
	btGpuDemo2dOCLWrap::copyArrayToDevice(btGpuDemo2dOCLWrap::m_dParams, hParams, sizeof(float) * 4 * 2); 
	{
		BT_PROFILE("btCuda_collisionBatchResolutionBox");
		
		int nIter=getSolverInfo().m_numIterations;
		btDispatcherInfo& dispatchInfo = getDispatchInfo();
		btScalar timeStep = dispatchInfo.m_timeStep;

	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, 1, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcPos);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, 2, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcVel);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, 3, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcRot);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, 4, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcAngVel);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, 9, sizeof(float),	(void*)&timeStep);

	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 3, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcPos);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 4, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcVel);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 5, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcRot);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 6, sizeof(cl_mem),	(void*)&btGpuDemo2dOCLWrap::m_dcAngVel);
	btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 12, sizeof(float),	(void*)&timeStep);

		for(int i=0;i<nIter;i++)
		{
//			btCuda_collisionWithWallBox(m_dcPos, m_dcVel, m_dcRot, m_dcAngVel,m_dShapeBuffer, m_dShapeIds, m_dInvMass,
//				partProps, boxProps, m_numObj + 1, timeStep);
			btGpuDemo2dOCLWrap::runKernelWithWorkgroupSize(GPUDEMO2D_KERNEL_COLLISION_WITH_WALL, m_numObj + 1);
//			int* pBatchIds = m_dBatchIds;
			int batchOffs = 0;
			for(int iBatch=0;iBatch < m_maxBatches;iBatch++)
			{
				int numConstraints = m_numInBatches[iBatch]; 
/*
				btCuda_collisionBatchResolutionBox( m_dIds, pBatchIds, numConstraints, m_numObj + 1,
													m_dcPos, m_dcVel,
													m_dcRot, m_dcAngVel,
													m_dLambdaDtBox,
													m_dContact, m_dInvMass,
													partProps, iBatch, timeStep);
*/
				btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 10, sizeof(int),	(void*)&iBatch);
				btGpuDemo2dOCLWrap::setKernelArg(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, 11, sizeof(int),	(void*)&batchOffs);
				btGpuDemo2dOCLWrap::runKernelWithWorkgroupSize(GPUDEMO2D_KERNEL_SOLVE_CONSTRAINTS, numConstraints);
//				pBatchIds += numConstraints;
				batchOffs += numConstraints;
			}
		}
	}
	copyDataFromGPU();
	writebackData();
	m_numSimStep++;
#endif //BT_USE_CUDA
}