Esempio n. 1
0
void start_paging(void* physbase, void* physfree){
	mark_kernel_pages_used(physbase,physfree);
	//	mark_kernel_pages_used(&(_binary_tarfs_start),&(_binary_tarfs_end));

	create_init_process();	
	cr3_content = init_process->cr3;
	map_all_memory_to_pageTables(cr3_content);
	checkLookUp(physbase,physfree,cr3_content);
//	_asm("sti");
}
void ReadASCII::rampThread(void)
{
	//Ramps SP values when the ramp is on
	double wait, rate, target, curSP, newSP, SPRBV;
	int ramping, rampOn, lookUpOn;

	lock();

	while (1)
	{
		//check running
		getIntegerParam(P_Ramping, &ramping);

		//check ramp mode
		getIntegerParam(P_RampOn, &rampOn);

		unlock();

		if ((!ramping) || (!rampOn)) {
			//wait for run to change
			epicsEventWait(eventId_);

			lock();

			continue;
		}

		lock();

		//get SP:RBV
		getDoubleParam(P_SPRBV, &SPRBV);

		//get current SP
		getDoubleParam(P_SPOut, &curSP);

		//get target
		getDoubleParam(P_Target, &target);

		if ((abs(SPRBV - target) < EPSILON) && (abs(curSP - target) < EPSILON))
		{
			setIntegerParam(P_Ramping, 0);
			continue;
		}

		callParamCallbacks();
		unlock(); 
		wait = 5.0; //default wait

		//wait
		epicsEventWaitWithTimeout(eventId_, wait);

		//check near final SP (Doesn't work as requires long time to write to Eurotherm) 
		//if (diff < (wait * rate))
		//{
		//	//wait less time
		//	wait = diff / rate;
		//}
		
		lock();

		//check rampOn (could have changed whilst waiting)
		getIntegerParam(P_RampOn, &rampOn);
		
		if (!rampOn)
		{
			//no longer ramping
			setIntegerParam(P_Ramping, 0);
			continue;
		}

		//rate may have changed whilst waiting
		getDoubleParam(P_RampRate, &rate);
			
		//SP may have changed
		getDoubleParam(P_SPOut, &curSP);

		//target may have changed
		double oldTarget = target;
		getDoubleParam(P_Target, &target);

		if (oldTarget != target)
		{
			//start back at current temp
			getDoubleParam(P_CurTemp, &curSP);
			setDoubleParam(P_SPOut, curSP);
			continue;
		}

		double diff = abs(target - curSP);

		if (diff < (wait * rate))
		{
			newSP = target;
		}else{
			if (curSP > target)
				rate = -rate;

			//update SP with wait*rate
			newSP = curSP + wait*rate;
		}

		setDoubleParam(P_SPOut, newSP);

		callParamCallbacks();

		//check PID table in use
		getIntegerParam(P_LookUpOn, &lookUpOn);

		if (lookUpOn)
		{
			checkLookUp(newSP, curSP);
		}
	}

}