Beispiel #1
0
/**
 * Loads a model from a file if needed or increases its refrence count.
 * @return Pointer to the loaded model.
 */
Model* ResourceManager::loadModel(const string filename) {
	map< string, pair<Model*, int> >::iterator moditer = models_.find(filename);
	Model* model = NULL;
	if(moditer != models_.end()) {
		pair<Model*, int> modref = moditer->second;
		model = modref.first;
		modref.second++;
	} else {
		//int fullpath_size = strlen(DIRECTORY_MODELS) + strlen(filename) +1;
		//char* fullpath = malloc(fullpath_size);
		//snprintf(fullpath, fullpath_size, "%s%s", DIRECTORY_MODELS, filename);
		DEBUG_A("FLAG1 '%s', '%s'", DIRECTORY_MOD.c_str(), filename.c_str());
		string fullpath = DIRECTORY_MOD + filename;
		DEBUG_A("FLAG2");
		model = RCBC_LoadFile(fullpath.c_str(), getImages());
		DEBUG_L("Loading model '%s'", fullpath.c_str());
		pair<Model*, int> modref(model, 1);
		models_.insert(pair<string, pair<Model*, int> >(filename, modref));
		//free(fullpath);
	}

	return model;
}
Beispiel #2
0
//
// Call at 1ms ISR - Part of ISR 
// ISR complete within 5uS
//
void my_TMR_ISR(void)
{
	unsigned char tFS=0;
	static u32 tPACC=0;
	static unsigned char tLED=0;
	static unsigned int tTMR=0;

#ifdef debug_isr
	DEBUG_H();
#endif

	tTMR++;
	if (tTMR>=200)
	{
		// Generate Sync. Task Flag on Every 100mS
		// Decouple it from ISR
		mTask_Sync_Flag = 1;
		mTMR_100ms +=2;
		tTMR = 0;
	}


//	Phase Accumulator to generate Flow Sensor count
//	60000 phase unit per cycle
//	n 		delta phase unit = n count / min
//  1 		delta phase unit = 1 count / min
//  3000 	delta phase unit = 3000 counts / min

	mDP = mFR;
	tPACC += mDP;

	if (tPACC>=60000)
	{
		tPACC = 0;
	}

	if (tPACC<30000)
	{	FS_O = 1;
	}
	else
	{	FS_O = 0;
  	}

	// Flow Sensor Input 0
	tFS = FS_I0;
	if ((tFS != mFS_CNT[0][1]) && (tFS==1))
		mFS_CNT[0][0]++;
	mFS_CNT[0][1] = tFS;	

	// Flow Sensor Input 1
	tFS = FS_I1;
	if ((tFS != mFS_CNT[1][1]) && (tFS==1))
		mFS_CNT[1][0]++;
	mFS_CNT[1][1] = tFS;	

	// Flow Sensor Input 2
	tFS = FS_I2;
	if ((tFS != mFS_CNT[2][1]) && (tFS==1))
		mFS_CNT[2][0]++;
	mFS_CNT[2][1] = tFS;	


 	tLED ++;
	if (tLED>=16)
	{
		tLED = 0;
	}


	if (mLED[0]>tLED)
	{
		LED_R_ON();		

	}		
	else
	{
		LED_R_OFF();

	}

	my_printQ();

#ifdef debug_isr
	DEBUG_L();
#endif

}