Exemple #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawLineCloud()
{
	Verify(texture2==0);
	Start_Timer(GOS_Draw_Time);

	for(int i=0;i<numVertices;i++)
	{
		if(((GOSVertex *)vertices)[i].x > Environment.screenWidth-1)
		{
			((GOSVertex *)vertices)[i].x = static_cast<Scalar>(Environment.screenWidth-1);
		}
		if(((GOSVertex *)vertices)[i].y > Environment.screenHeight-1)
		{
			((GOSVertex *)vertices)[i].y = static_cast<Scalar>(Environment.screenHeight-1);
		}
	}

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		gos_DrawLines( (GOSVertex *)vertices, numVertices);
	}
	Stop_Timer(GOS_Draw_Time);
}
Exemple #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawTriList()
{
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		if(texture2==0)
		{
			GOSVertex *v = (GOSVertex *)vertices;
			if ((v[0].z >= 0.0f) &&
				(v[0].z < 1.0f) &&
				(v[1].z >= 0.0f) &&  
				(v[1].z < 1.0f) && 
				(v[2].z >= 0.0f) &&  
				(v[2].z < 1.0f))
			{
				gos_DrawTriangles( (GOSVertex *)vertices, numVertices);
			}
		}
		else
		{
			STOP(("GOS doesnt suppert gos_DrawTriangles for gos_VERTEX_2UV yet."));
//			gos_DrawTriangles( (GOSVertex2UV *)vertices, numVertices);
		}
	}
	Stop_Timer(GOS_Draw_Time);
}
Exemple #3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawPointCloud()
{
	Verify(texture2==0);
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{

		GOSVertex pArray[32*3];

		float size = (float)numIndices;
		
		if( size == 0 )
		{
			size = 2.4f;
		}
		else
		{
			size *= 2.4f;
		}

		int Triangle = 0, Vertex = 0;
	//
	// Warning! - These points need clipping!
	//
		for( int i=numVertices; i; i-- )
		{
			pArray[Triangle+0] = *((GOSVertex *)vertices + Vertex);
			pArray[Triangle+1] = *((GOSVertex *)vertices + Vertex);
			pArray[Triangle+2] = *((GOSVertex *)vertices + Vertex);

			pArray[Triangle+1].x += size;
			pArray[Triangle+2].y += size;

			Triangle +=3;
			Vertex++;

			if( Triangle==32*3 || i==1)
			{
				if ((pArray[0].z >= 0.0f) &&
					(pArray[0].z < 1.0f) &&
					(pArray[1].z >= 0.0f) &&  
					(pArray[1].z < 1.0f) && 
					(pArray[2].z >= 0.0f) &&  
					(pArray[2].z < 1.0f))
				{
					gos_DrawTriangles( pArray, Triangle );
				}

				Triangle=0;
			}
		}
	}
	Stop_Timer(GOS_Draw_Time);
}
Exemple #4
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	SortData::LoadAlphaFromLineCloud(SortAlpha**)
{
	Start_Timer(Alpha_Sorting_Time);
	STOP(("Not implemented"));
	Stop_Timer(Alpha_Sorting_Time);

	return 0;
}
Exemple #5
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawTriIndexedList()
{
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		WORD newIndicies[4096];
		long startIndex = 0;
		GOSVertex *v = (GOSVertex *)vertices;
		for (long i=0;i<numIndices;i+=3)
		{
			if (((v[indices[i]].z >= 0.0f) &&   (v[indices[i]].z < 1.0f)) &&
				((v[indices[i+1]].z >= 0.0f) && (v[indices[i+1]].z < 1.0f)) &&
				((v[indices[i+2]].z >= 0.0f) && (v[indices[i+2]].z < 1.0f)))
			{
				//Copy these indicies to new array.
				newIndicies[startIndex] = indices[i];
				newIndicies[startIndex+1] = indices[i+1];
				newIndicies[startIndex+2] = indices[i+2];
				startIndex += 3;
			}
		}

		if (startIndex)
		{
			if(texture2==0)
			{
				gos_RenderIndexedArray( (GOSVertex *)vertices, numVertices, newIndicies, startIndex);
			}
			else
			{
				gos_RenderIndexedArray( (GOSVertex2UV *)vertices, numVertices, indices, numIndices);
			}
		}
	}
	Stop_Timer(GOS_Draw_Time);
}
Exemple #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	SortData::LoadAlphaFromTriIndexedList(SortAlpha **alpha)
{
	Start_Timer(Alpha_Sorting_Time);
	int i, index = 0, end = numIndices/3;
	Verify(texture2==0);

	for(i=0;i<end;i++)
	{
		alpha[i]->state = &state;

		alpha[i]->triangle[0] = ((GOSVertex *)vertices)[indices[index++]];
		alpha[i]->triangle[1] = ((GOSVertex *)vertices)[indices[index++]];
		alpha[i]->triangle[2] = ((GOSVertex *)vertices)[indices[index++]];

		alpha[i]->distance = alpha[i]->triangle[0].z;
		alpha[i]->distance += alpha[i]->triangle[1].z;
		alpha[i]->distance += alpha[i]->triangle[2].z;
	}
	Stop_Timer(Alpha_Sorting_Time);

	return i;
}
Exemple #7
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawQuads()
{
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		if(texture2==0)
		{
//			gos_DrawTriangles( (GOSVertex *)vertices, numVertices);
			gos_DrawQuads( (GOSVertex *)vertices, numVertices);
		}
		else
		{
			STOP(("GOS doesnt suppert gos_DrawQuads for gos_VERTEX_2UV yet."));
//			gos_DrawQuads( (GOSVertex2UV *)vertices, numVertices);
		}

	}
	Stop_Timer(GOS_Draw_Time);
}
UnitQuaternion&
	UnitQuaternion::FastLerp(
		const UnitQuaternion& p, 
		const UnitQuaternion& q, 
		Scalar t
	)
{


	if (!UseFastLerp)
		return Lerp(p,q,t);


	Start_Timer(SlerpTime);

	Set_Statistic(SlerpCount, SlerpCount+1);

	Verify(quaternionFastLerpTableBuilt);

	Scalar cosom,sclp,sclq;
	
	cosom = p.x*q.x + p.y*q.y + p.z*q.z + p.w*q.w;


	if ( (1.0f + cosom) > 0.01f)
	{
		// usual case 
	

		
		if ( (1.0f - cosom) > 0.00001f ) 
		{ 
			//usual case
			
			

			//table_entry = (int)Scaled_Float_To_Bits(cosom, MinCosom, MaxCosom, 10);


			float tabled_float =  cosom - MinCosom;
			int cos_table_entry = Truncate_Float_To_Word(((tabled_float*CosomRangeOverOne) * CosBiggestNumber));
			
			Verify(cos_table_entry >= 0);
			Verify(cos_table_entry <= QuaternionLerpTableSize);


#if 0
			sclp = Sin((1.0f - t)*Omega_Table[cos_table_entry]) * SinomOverOne_Table[cos_table_entry];
			sclq = Sin(t*Omega_Table[cos_table_entry]) * SinomOverOne_Table[cos_table_entry];
	
#else
		
			float difference, percent, lerped_sin;


			tabled_float =  ((1.0f - t)*Omega_Table[cos_table_entry]) - MinSin;
			int sclp_table_entry = Truncate_Float_To_Word(((tabled_float*SinRangeOverOne) * SinBiggestNumber));


			if (!(sclp_table_entry < SinTableSize))
			{
				Max_Clamp(sclp_table_entry, SinTableSize-1);
			}


			Verify(sclp_table_entry >= 0 && sclp_table_entry < SinTableSize);
			difference = tabled_float - (SinIncrement * sclp_table_entry);
			percent = difference / SinIncrement;
			int lerp_to_entry = sclp_table_entry + 1;
			Max_Clamp(lerp_to_entry, SinTableSize-1);
			lerped_sin = Stuff::Lerp(Sin_Table[sclp_table_entry], Sin_Table[lerp_to_entry], percent);
			sclp = lerped_sin * SinomOverOne_Table[cos_table_entry];



			tabled_float =  (t*Omega_Table[cos_table_entry]) - MinSin;
			int sclq_table_entry = Truncate_Float_To_Word(((tabled_float*SinRangeOverOne) * SinBiggestNumber));
			Verify(sclq_table_entry >= 0 && sclq_table_entry < SinTableSize);
			difference = tabled_float - (SinIncrement * sclq_table_entry);
			percent = difference / SinIncrement;
			lerp_to_entry = sclq_table_entry + 1;
			Max_Clamp(lerp_to_entry, SinTableSize-1);
			lerped_sin = Stuff::Lerp(Sin_Table[sclq_table_entry], Sin_Table[lerp_to_entry], percent);
			sclq = lerped_sin * SinomOverOne_Table[cos_table_entry];
#endif
			
		}
		else 
		{ 
			// ends very close -- just lerp
			sclp = 1.0f - t;
			sclq = t;

			
		}


		x = sclp*p.x + sclq*q.x;
		y = sclp*p.y + sclq*q.y;
		z = sclp*p.z + sclq*q.z;
		w = sclp*p.w + sclq*q.w;

		
	}
	else 
	{



		//SPEW(("jerryeds","SPECIAL CASE"));
		/* p and q nearly opposite on sphere-- this is a 360 degree
		   rotation, but the axis of rotation is undefined, so
		   slerp really is undefined too.  So this apparently picks 
		   an arbitrary plane of rotation. However, I think this 
		   code is incorrect.
		   */

		//really we want the shortest distance.  They are almost on top of each other.
	
		UnitQuaternion r;
		r.Subtract(q, p);

		Vector3D scaled_rotation;
		scaled_rotation = r;
		scaled_rotation *= t;
		UnitQuaternion scaled_quat;
		scaled_quat = scaled_rotation;

		Multiply(scaled_quat, p);

		Normalize();

	}


	Stop_Timer(SlerpTime);

	return *this;

}
UnitQuaternion &UnitQuaternion::Lerp(const UnitQuaternion& p, const UnitQuaternion& q, Scalar t)
{

	Start_Timer(SlerpTime);

	Set_Statistic(SlerpCount, SlerpCount+1);

	Scalar omega,cosom,sinom,sclp,sclq;
	//UnitQuaternion qt;


	//UnitQuaternion q = q_temp;
	//UnitQuaternion p = p_temp;

	cosom = p.x*q.x + p.y*q.y + p.z*q.z + p.w*q.w;


	if ( (1.0f + cosom) > 0.01f)
	{
		// usual case 
	
		
		if ( (1.0f - cosom) > 0.00001f ) 
		{ 
			//usual case 
			omega = Arccos(cosom);
			sinom = Sin(omega);
			
			//SPEW(("jerryeds","omega:%f sinom:%f", omega, sinom));

			sclp = Sin((1.0f - t)*omega) / sinom;
			sclq = Sin(t*omega) / sinom;
		
			//SPEW(("jerryeds", "* %f %f", sclp, sclq));
		}
		else 
		{ 
			// ends very close -- just lerp
			sclp = 1.0f - t;
			sclq = t;

			//SPEW(("jerryeds", "# %f %f", sclp, sclq));
		}


		x = sclp*p.x + sclq*q.x;
		y = sclp*p.y + sclq*q.y;
		z = sclp*p.z + sclq*q.z;
		w = sclp*p.w + sclq*q.w;

		//SPEW(("jerryeds", "r:<%f,%f,%f,%f>",x,y,z,w));
	}
	else 
	{
		//SPEW(("jerryeds","SPECIAL CASE"));
		/* p and q nearly opposite on sphere-- this is a 360 degree
		   rotation, but the axis of rotation is undefined, so
		   slerp really is undefined too.  So this apparently picks 
		   an arbitrary plane of rotation. However, I think this 
		   code is incorrect.
		   */

		//really we want the shortest distance.  They are almost on top of each other.

		UnitQuaternion r;
		r.Subtract(q, p);

		Vector3D scaled_rotation;
		scaled_rotation = r;
		scaled_rotation *= t;
		UnitQuaternion scaled_quat;
		scaled_quat = scaled_rotation;

		Multiply(scaled_quat, p);

	}

	Stop_Timer(SlerpTime);

	return *this;
}
Exemple #10
0
void MRFI_RxCompleteISR()
{
	mrfiPacket_t PacketRecieved;
	mPacket Packet;
	char rssi ;

	uint8_t ID_Network_tmp, ID_Beacon_tmp ,src ,i ,data;
	uint32_t voisin_voisin;					//the voisin of voisin

	MRFI_Receive(&PacketRecieved);
	RecievemPacket(&PacketRecieved ,&Packet);

	if(Packet.flag == FBEACON){	
		etat.Surveille_Cnt = ( etat.Surveille_Cnt + 1 )%65535;

		ID_Network_tmp = Packet.payload.beacon.ID_Network;
		ID_Beacon_tmp  = Packet.payload.beacon.ID_Slot;
		src  = Packet.src;
		voisin_voisin = Packet.payload.beacon.Voisin;
		rssi = PacketRecieved.rxMetrics[0]; 
		if(rssi > -84){			//seuil avec pwr(0) ,distance 70cm
			etat.check[src-1] = (etat.check[src-1] + 1)%65535;	//make sure if the voisin is there
			Add_router(&etat , src, voisin_voisin);		//every time it recieve the beacon , update the route table
		}
/*
		print_8b(ID_Network_tmp);
		print_8b(ID_Beacon_tmp);
		print(" ");
		print_8b(-rssi);
		print("\n\r");
*/

		if(rssi < -84 && etat.ID_Beacon == ID_Beacon_tmp && etat.ID_Beacon !=0 && etat.HOST == IS_NOT_CREATER){ //if the beacon source go far , choose another
			Stop_Timer();
		}else{
			if(etat.synchrone == 0 && etat.HOST == IS_NOT_CREATER){	
				Stop_Timer();
				etat.ID_Network = ID_Network_tmp;		 
				etat.ID_Beacon  = ID_Beacon_tmp;
			 	etat.synchrone = 1;			 

				if(etat.MAC > etat.ID_Beacon ){
					etat.state = WAIT_BEACON ;	//change the state
					timer_send_beacon(&etat);	
				}else{
					etat.state = WAIT_SYNCHRONE ;	//change the state
					timer_synchrone(&etat);
				}	
			} 
			if(ID_Network_tmp < etat.ID_Network){			//if there is 2 network collision
				if(etat.HOST == IS_CREATER){
					etat.HOST = IS_NOT_CREATER;
					P1OUT ^= 0x02;   			//jaune led
				}	
				Stop_Timer();
				etat.ID_Network = ID_Network_tmp;		 
				etat.ID_Beacon  = ID_Beacon_tmp;
			 	etat.synchrone = 1;			 

				if(etat.MAC > etat.ID_Beacon ){
					etat.state = WAIT_BEACON;	//change the state
					timer_send_beacon(&etat);	
				}else{
					etat.state = WAIT_SYNCHRONE ;	//change the state
					timer_synchrone(&etat);
				}			
			}
		}
	}else if(Packet.flag == FDATA){
		if(Packet.payload.data.Next_hop == etat.MAC){ 	//if next hop is him, relay and change the next hop
			if(Packet.dst == etat.MAC){			//if it is really for me
				etat.Dst = Packet.src;
				if(UART_MODE!=2){			//change mode to type if recieve a paquet
					UART_MODE = 2;
					print("\n\rRecieved message from: ");
					print_8b(etat.Dst);
					print("\n\r");
				}
				for (i=0;i<Packet.length-11;i++) {
					data = Packet.payload.data.data[i];
					EnQueue(&etat.FIFO_Recieve,data);
				}
			}else{						//if it just nedd relay
				P1OUT ^= 0x02; 
				PacketRecieved.frame[10] = Find_next_hop(&etat , Packet.dst);
				MRFI_Transmit(&PacketRecieved, MRFI_TX_TYPE_CCA);
				//MRFI_Transmit(&PacketRecieved, MRFI_TX_TYPE_FORCED);	
			}
		}
		if(Packet.dst == BROADCAST){				//if it is message broadcast
			for (i=0;i<Packet.length-11;i++) {
				data = Packet.payload.data.data[i];
				EnQueue(&etat.FIFO_Recieve,data);
			}
		}
	}else if(Packet.flag == FRIP){		//recieve the packet of rip then update the router table
		Update_rip(&etat ,&Packet);
	}
}
Exemple #11
0
interrupt(TIMERB0_VECTOR) Timer_B0(void)
{
	etat.Counter--;
	if(etat.Counter == 0){
		Start_Timer_Surveille();		//the timer A0 is closed when we use CCA, we must check it and start it
		Stop_Timer();
		if(etat.state == WAIT_SCAN && etat.ID_Network == NO_NETWORK){
	 		etat.ID_Network = etat.MAC;
	  		etat.HOST = IS_CREATER;
		 	etat.synchrone = 1;			 
			etat.state = WAIT_SYNCHRONE;		//change the state
			timer_synchrone(&etat);
			Send_beacon(&etat);
			P1OUT |= 0x02;   			//jaune led
	 	}else{
			switch(etat.state){
				case WAIT_BEACON : 
					if(etat.HOST == IS_NOT_CREATER){
						etat.state = WAIT_SYNCHRONE;	//change the state
						if(etat.ID_Beacon < etat.MAC){
							timer_synchrone(&etat);
							P1OUT ^= 0x01;   			//rouge led
							Send_beacon(&etat);			//send beacon
						}else{			
							Stop_Timer();	
						}
					}
					break;
				case WAIT_SYNCHRONE : 
					etat.state = WAIT_MESSAGE;	//change the state
					//time for message
					timer_message(&etat);	
					if(etat.HOST == IS_NOT_CREATER ){
					 	etat.synchrone = 0;			 
					}

					if(etat.Dst != 0){
						Send_message(&etat, &etat.FIFO_Send ,etat.Dst);
					}
					Recieve_message(&etat, &etat.FIFO_Recieve);

					if(RIP_Prepared == 1){			//every 3s ,send the rip
						Tidy_table(&etat);		// clear the dirty data
						Send_rip(&etat);
						RIP_Prepared = 0;
					}
					break;
				case WAIT_MESSAGE :
					etat.state = WAIT_SLEEP;	//change the state
					//time for sleep
					timer_sleep(&etat);
					Sleep();
					break;
				case WAIT_SLEEP :
					if(etat.HOST == IS_NOT_CREATER ){
						etat.state = WAIT_BEACON;	//change the state

						if(etat.ID_Beacon < etat.MAC){
							Stop_Timer();
						}else{
							timer_send_beacon(&etat);
						}
					}else{						//the host
						etat.state = WAIT_SYNCHRONE;
						timer_synchrone(&etat);
						P1OUT ^= 0x01;   			//rouge led
						Send_beacon(&etat);
					}
					break;
				default:
					break;		
			}
		}

	}
}
Exemple #12
0
int main (int argc, char** argv)
/*****/
  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;

  /* Arguments */
#if HOST_DEBUG
  if (argc > 2)
  {
     do_fprintf (stdout, "Usage: %s [number of loops]\n", argv[0]);
     exit (1);
  }
  if (argc == 2)
  {
     Number_Of_Runs = atoi (argv[1]);
  } else
#endif
  {
     Number_Of_Runs = NUMBER_OF_RUNS;
  }
  if (Number_Of_Runs <= 0)
  {
     Number_Of_Runs = NUMBER_OF_RUNS;
  }

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) alloca (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) alloca (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

#if HOST_DEBUG
  do_fprintf (stdout, "\n");
  do_fprintf (stdout, "Dhrystone Benchmark, Version %s\n", Version);
  if (Reg)
  {
    do_fprintf (stdout, "Program compiled with 'register' attribute\n");
  }
  else
  {
    do_fprintf (stdout, "Program compiled without 'register' attribute\n");
  }
  do_fprintf (stdout, "Using %s, HZ=%d\n", CLOCK_TYPE, HZ);
  do_fprintf (stdout, "\n");
#endif

  Done = false;
  while (!Done) {
#if HOST_DEBUG
    do_fprintf (stdout, "Trying %d runs through Dhrystone:\n", Number_Of_Runs);
#endif

    /***************/
    /* Start timer */
    /***************/

    Start_Timer();
    setStats(1);

    for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
    {

      Proc_5();
      Proc_4();
	/* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
      Int_1_Loc = 2;
      Int_2_Loc = 3;
      strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
      Enum_Loc = Ident_2;
      Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
	/* Bool_Glob == 1 */
      while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
      {
	Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
	  /* Int_3_Loc == 7 */
	Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
	  /* Int_3_Loc == 7 */
	Int_1_Loc += 1;
      } /* while */
	/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
      Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
	/* Int_Glob == 5 */
      Proc_1 (Ptr_Glob);
      for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
			       /* loop body executed twice */
      {
	if (Enum_Loc == Func_1 (Ch_Index, 'C'))
	    /* then, not executed */
	  {
	  Proc_6 (Ident_1, &Enum_Loc);
	  strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
	  Int_2_Loc = Run_Index;
	  Int_Glob = Run_Index;
	  }
      }
	/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
      Int_2_Loc = Int_2_Loc * Int_1_Loc;
      Int_1_Loc = Int_2_Loc / Int_3_Loc;
      Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
	/* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
      Proc_2 (&Int_1_Loc);
	/* Int_1_Loc == 5 */

    } /* loop "for Run_Index" */

    /**************/
    /* Stop timer */
    /**************/

    setStats(0);
    Stop_Timer();

    User_Time = End_Time - Begin_Time;

    if (User_Time < Too_Small_Time)
    {
      do_fprintf (stdout, "Measured time too small to obtain meaningful results\n");
      Number_Of_Runs = Number_Of_Runs * 10;
      do_fprintf (stdout, "\n");
    } else Done = true;
  }

  do_fprintf (stderr, "Final values of the variables used in the benchmark:\n");
  do_fprintf (stderr, "\n");
  do_fprintf (stderr, "Int_Glob:            %d\n", Int_Glob);
  do_fprintf (stderr, "        should be:   %d\n", 5);
  do_fprintf (stderr, "Bool_Glob:           %d\n", Bool_Glob);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "Ch_1_Glob:           %c\n", Ch_1_Glob);
  do_fprintf (stderr, "        should be:   %c\n", 'A');
  do_fprintf (stderr, "Ch_2_Glob:           %c\n", Ch_2_Glob);
  do_fprintf (stderr, "        should be:   %c\n", 'B');
  do_fprintf (stderr, "Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  do_fprintf (stderr, "        should be:   %d\n", 7);
  do_fprintf (stderr, "Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  do_fprintf (stderr, "        should be:   Number_Of_Runs + 10\n");
  do_fprintf (stderr, "Ptr_Glob->\n");
  do_fprintf (stderr, "  Ptr_Comp:          %d\n", (long) Ptr_Glob->Ptr_Comp);
  do_fprintf (stderr, "        should be:   (implementation-dependent)\n");
  do_fprintf (stderr, "  Discr:             %d\n", Ptr_Glob->Discr);
  do_fprintf (stderr, "        should be:   %d\n", 0);
  do_fprintf (stderr, "  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 2);
  do_fprintf (stderr, "  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 17);
  do_fprintf (stderr, "  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  do_fprintf (stderr, "Next_Ptr_Glob->\n");
  do_fprintf (stderr, "  Ptr_Comp:          %d\n", (long) Next_Ptr_Glob->Ptr_Comp);
  do_fprintf (stderr, "        should be:   (implementation-dependent), same as above\n");
  do_fprintf (stderr, "  Discr:             %d\n", Next_Ptr_Glob->Discr);
  do_fprintf (stderr, "        should be:   %d\n", 0);
  do_fprintf (stderr, "  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 18);
  do_fprintf (stderr, "  Str_Comp:          %s\n",
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  do_fprintf (stderr, "Int_1_Loc:           %d\n", Int_1_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 5);
  do_fprintf (stderr, "Int_2_Loc:           %d\n", Int_2_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 13);
  do_fprintf (stderr, "Int_3_Loc:           %d\n", Int_3_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 7);
  do_fprintf (stderr, "Enum_Loc:            %d\n", Enum_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "Str_1_Loc:           %s\n", Str_1_Loc);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  do_fprintf (stderr, "Str_2_Loc:           %s\n", Str_2_Loc);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  do_fprintf (stderr, "\n");


#if HOST_DEBUG
    Microseconds = (float) User_Time * Mic_secs_Per_Second 
                        / ((float) HZ * ((float) Number_Of_Runs));
    Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
                        / (float) User_Time;

    do_fprintf (stdout, "Microseconds for one run through Dhrystone: ");
    do_fprintf (stdout, "%10.1f \n", Microseconds);
    do_fprintf (stdout, "Dhrystones per Second:                      ");
    do_fprintf (stdout, "%10.0f \n", Dhrystones_Per_Second);
    do_fprintf (stdout, "\n");
#endif

  return 0;
}
Exemple #13
0
void main(void)
{

		init_DigIO();
	  	init_timer();
	   	
		init_adc();	   ////
		init_SWTimer();   
     // Enable peripherial interrupts and start processing
     PEIE = 1; // Enable peripheral interrupt
     GIE = 1; // Enable global interrupt
 Start_Timer(TIMER_3,10); 
unsigned char tempcounter;
//Switch Off alarm and heater;
alarm_on();
heater_off();
while (1)
	{


if (GetTimer_State(TIMER_3) ==TIMER_EXPIRED)
{
 Start_Timer(TIMER_3,10); // Call every 10ms cyclic timer

if(Read_Adc_E1() == TRUE)//true
{

WaterSensed_State = Read_Adc_E0();
/*

if(WaterSensed_State == E0_E1_SHORT)
{
	alarm_on();
	heater_on();

}
else
{
	alarm_off();
	heater_off();


}
*/

				
	            
			//-------------------------------------------------------------------------------------
				if ((WaterSensed_PrevState == E0_E1_SHORT  ) && ( WaterSensed_State == E0_E1_OPEN ))
				{
				Start_Timer(TIMER_0,5000); // For 5 Seconds
                pressuresw_Flag = FALSE;
				}
				else if (GetTimer_State(TIMER_0) ==TIMER_EXPIRED)
				{
				alarm_on();
				heater_off();
	         
				Stop_Timer(TIMER_0);
				
				}
			//-------------------------------------------------------------------------------------
				
				 
		 

	

//-------------------------------------------------------------------------------------
				if ((WaterSensed_PrevState == E0_E1_OPEN )  && ( WaterSensed_State == E0_E1_SHORT ))
			{
				Start_Timer(TIMER_1,5000);// For 5 Seconds
				}
			else  if (GetTimer_State(TIMER_1) ==TIMER_EXPIRED)
				{


				alarm_off();
				pressuresw_Flag = TRUE;
				Stop_Timer(TIMER_1);
				
				}

WaterSensed_PrevState =WaterSensed_State;
			//-------------------------------------------------------------------------------------
			
			
				if (E0_E1_UNKNOWN == WaterSensed_State) //ADC E0 is inbetween 1 and 2 Volts which is error case;
				{
					alarm_on();
					heater_off();
				
				}

			// Delay 2 sec
			//------------Pressure switch case----true---------------------------------------------------------------------
			
if (pressuresw_Flag)
  {
			Switch_State = read_pressure_switch();
			if ((Switch_PrevState == FALSE )&& (Switch_State == TRUE))
			{
				Start_Timer(TIMER_2,2000);
			
			}

			if ((GetTimer_State(TIMER_2) ==TIMER_EXPIRED) &&  (Switch_State == TRUE))		
			{
			heater_on();
			alarm_off();
			}
		
		
			 if(Switch_State == FALSE)
				{
				Stop_Timer(TIMER_2);
				heater_off();
			
				}
   }
		

			//----------------------------------------------------------------------------------------

	Switch_PrevState=Switch_State;
}

	else	{ // E1 voltage is  other than  1.25
		alarm_on();
		heater_off();
		}



 // While ends
}
}
}