OsclReturnCode OmxDecTestBase::ProcessCallbackEventHandler(OsclAny* P)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackEventHandler() - Processing the EventHandler Callback IN"));

    // re-cast the pointer
    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;

    OMX_HANDLETYPE aComponent = ED->hComponent;
    OMX_PTR aAppData = ED->pAppData;
    OMX_EVENTTYPE aEvent = ED->eEvent;
    OMX_U32 aData1 = ED->nData1;
    OMX_U32 aData2 = ED->nData2;
    OMX_PTR aEventData = ED->pEventData;

    EventHandler(aComponent, aAppData, aEvent, aData1, aData2, aEventData);

    // release the allocated memory when no longer needed
    ED->hComponent = NULL;
    ED->nData1 = 0;
    ED->nData2 = 0;
    ED->pAppData = NULL;
    ED->pEventData = NULL;

    ipThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackEventHandler() - OUT"));

    return OsclSuccess;
}
Пример #2
0
void Engine::GameLoop()
{
    SDL_Event event;

	while(!State.Quit)
	{
		Input::Update();
		// Update Input Here
		while (SDL_PollEvent(&event))
		{
			Input::EventHandler(&event);
			BaseEventHandler(event);
			EventHandler(event);
			if(CurrentLevel != nullptr)
			{
				CurrentLevel->EventHandler(&event);
			}
		}

		Renderer->RenderClear();

		// Rendering
		Render();

		Renderer->RenderPresent();

	}
}
Пример #3
0
MainForm::MainForm()
{
    SuspendLayout();

    _humanBoard = gcnew Board();
    _computerBoard = gcnew Board(false);

    _humanPlayer = gcnew HumanPlayer("Þaidëjas", _computerBoard);
    _computerPlayer = gcnew ComputerPlayer("Kompiuteris");


    _scoreboard = gcnew ScoreBoard(_humanPlayer, _computerPlayer, 10, 100);
    _controller = gcnew GameController(_humanPlayer, _computerPlayer, _humanBoard, _computerBoard, _scoreboard);

    _shuffleButton = CreateButton(ShuffleCharacter.ToString(), ButtonBackColor);
    _newGameButton = CreateButton(NewGameCharacter.ToString(), ButtonBackColor);
    _startGameButton = CreateButton(StartGameCharacter.ToString(), ButtonBackColor);

    SetupWindow();
    LayoutControls();

    _scoreboard->GameEnded += gcnew EventHandler(this, &MainForm::OnGameEnded);

    _shuffleButton->Click += gcnew System::EventHandler(this, &MainForm::OnShuffleButtonClick);
    _startGameButton->Click += gcnew System::EventHandler(this, &MainForm::OnStartGameButtonClick);
    _newGameButton->Click += gcnew System::EventHandler(this, &MainForm::OnNewGameButtonClick);

    ResumeLayout();

    StartNewGame();
};
Пример #4
0
int
Game::Execute ()
{
	if( Init() == false )
		return 1;
	else{
		pTimer = new Timer();

		m_IsRunning = true;

		SDL_Event event;

		while( m_IsRunning ){
			pTimer->start();
			
			while( SDL_PollEvent( &event ) ){
				EventHandler( &event );
			}	

			Update();

			Render();

			//Limit max frame rate per second( FPS )
			if( pTimer->getTicks() < 1000 / 60 )
				SDL_Delay( ( 1000 / 60 ) - pTimer->getTicks() );
		}
	}	
	return 0;
}
Пример #5
0
void one() {
#ifndef TEST_EMSCRIPTEN_SDL_SETEVENTHANDLER
  SDL_Event event;
  while (SDL_PollEvent(&event)) {
    EventHandler(0, &event);
  }
#endif
}
Пример #6
0
	TiendaEscena::TiendaEscena() {
		onTimerTick = gcnew EventHandler(this, &TiendaEscena::timerTick);
		onKeyDown = gcnew KeyEventHandler(this, &TiendaEscena::teclaDown);
		onMouseClick = gcnew MouseEventHandler(this, &TiendaEscena::mouseClick);
		modo_comprar = false;
		modo_vender = true;
		crearCartas();
	}
Пример #7
0
/////////////////////////////////////////////////////////////////////////
// Programme principal
/////////////////////////////////////////////////////////////////////////
int main()
{
    printf("Demarrage du programme\n\r") ;
    Init() ;

    while(true) {

        // Appel au gestionnaire d'evenements
        giEvent = EventHandler() ;
        // Appel a la machine a etats
        Algo() ;
    }
}
Пример #8
0
void LiveInLight (void){
	PORTB &= ~(1<<LedPin); // Light-up LED
	PWMStop();
	while (1){
		EnableInput ();
		DeepSleep();
		DisableInput ();
		if (Valto != None) {
			EventHandler ();
			// if key pressed then shutdown
			if (Valto==KeyPressed) break; 
		}
	}
	PWMStart(250);
	PORTB |= (1<<LedPin); // Shutdown LED
}
Пример #9
0
void LightUp (void){
	uint8_t i;
	PWMStart(0);
	// Enable shutdown at Light-up
	for (i=0; i<=250; i++){
		PWMSet (i);
		EnableInput ();
		if (i<PWMStepOver) Wait (PWMSlowDelay);
		else Wait (PWMQuickDelay);
		DisableInput ();
		if (Valto != None) {
			EventHandler ();
			// if key pressed then shutdown
			if (Valto==KeyPressed) break; 
		}
	}
}
Пример #10
0
int main (void){
	// Setup IO
	DDRB  = (0<<PB0)|(1<<PB1)|(0<<PB2)|(0<<PB3)|(0<<PB4);
	PORTB = (1<<PB0)|(1<<PB1)|(1<<PB2)|(0<<PB3)|(0<<PB4); // VCC-based LED
	
	while (1){
		EnableInput ();
		DeepSleep();
		DisableInput ();
		// **** Why wake? ****
		EventHandler();
		if (Valto==KeyPressed) {
			Valto = None;
			Wait (_2_s);
			LightUp();
			if (Valto == None) LiveInLight();
			LightDown();
		}
	}
}
Пример #11
0
	CampusEscena::CampusEscena()
	{
		onTimerTick = gcnew EventHandler(this, &CampusEscena::timerTick);
		onKeyDown = gcnew KeyEventHandler(this, &CampusEscena::teclaDown);
		onKeyUp = gcnew KeyEventHandler(this, &CampusEscena::teclaUp);
		onMouseClick = gcnew MouseEventHandler(this, &CampusEscena::mouseClick);

		Mapas::plazuela_mapa = gcnew PlazuelaMapa();
		Mapas::pabellonA_mapa = gcnew PabellonAMapa();
		Mapas::pabellonB_mapa = gcnew PabellonBMapa();
		Mapas::sotano_mapa = gcnew SotanoMapa();
		Mapas::jardin_mapa = gcnew JardinMapa();
		Mapa::mapa_actual = Mapas::plazuela_mapa;

		Marco::marco = gcnew Marco(gcnew Posicion(9, 9, true));
		PROFESORES::Profesor1 = gcnew Profesor(1, Mapas::plazuela_mapa, gcnew Posicion(16, 3, true));
		PROFESORES::Profesor2 = gcnew Profesor(3, Mapas::pabellonB_mapa, gcnew Posicion(16, 11, true));
		PROFESORES::Profesor3 = gcnew Profesor(5, Mapas::sotano_mapa, gcnew Posicion(16, 6, true));
		PROFESORES::Profesor4 = gcnew Profesor(7, Mapas::jardin_mapa, gcnew Posicion(11, 4, true));
		PROFESORES::Profesor5 = gcnew Profesor(9, Mapas::pabellonA_mapa, gcnew Posicion(2, 10, true));
	}
Пример #12
0
//=========================================================================
//----- (00000148) --------------------------------------------------------
__myevic__ void Main()
{
	InitDevices();

	InitVariables();

	// Enable chip temp sensor sampling by ADC
	if ( ISRX300 )
	{
		SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk;
	}

	InitHardware();

	myprintf( "\n\nJoyetech APROM\n" );
	myprintf( "CPU @ %dHz(PLL@ %dHz)\n", SystemCoreClock, PllClock );

	SetBatteryModel();

	gFlags.sample_vbat = 1;
	ReadBatteryVoltage();

	gFlags.sample_btemp = 1;
	ReadBoardTemp();

	InitDisplay();
	MainView();
	SplashTimer = 3;

	CustomStartup();

	if ( !PD3 )
	{
		DrawScreen();
		while ( !PD3 )
			;
	}

	while ( 1 )
	{
		while ( gFlags.playing_fb )
		{
			// Flappy Bird game loop
			fbCallTimeouts();
			if ( gFlags.tick_100hz )
			{
				// 100Hz
				gFlags.tick_100hz = 0;
				ResetWatchDog();
				TimedItems();
				SleepIfIdle();
				GetUserInput();
				if ( !PE0 )
					SleepTimer = 3000;
			}
			if ( gFlags.tick_10hz )
			{
				// 10Hz
				gFlags.tick_10hz = 0;
				DataFlashUpdateTick();
			}
		}

		if ( gFlags.firing )
		{
			ReadAtoCurrent();
		}

		if ( gFlags.tick_5khz )
		{
			// 5000Hz
			gFlags.tick_5khz = 0;

			if ( gFlags.firing )
			{
				RegulateBuckBoost();
			}
		}

		if ( gFlags.tick_1khz )
		{
			// 1000Hz
			gFlags.tick_1khz = 0;

			if ( gFlags.firing )
			{
				ReadAtomizer();

				if ( ISMODETC(dfMode) )
				{
					if ( gFlags.check_mode )
					{
						CheckMode();
					}
					TweakTargetVoltsTC();
				}
				else if ( ISMODEVW(dfMode) )
				{
					TweakTargetVoltsVW();
				}
			}

			if ( dfStatus.vcom )
			{
				VCOM_Poll();
			}
		}

		if ( gFlags.tick_100hz )
		{
			// 100Hz
			gFlags.tick_100hz = 0;

			ResetWatchDog();

			if ( gFlags.read_battery )
			{
				gFlags.read_battery = 0;
			}

			TimedItems();
			SleepIfIdle();
			ReadBatteryVoltage();
			ReadBoardTemp();

			if ( gFlags.firing && BoardTemp >= 70 )
			{
				Overtemp();
			}

			if ( ISVTCDUAL )
			{
				BatteryChargeDual();
			}
			else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 )
			{
				BatteryCharge();
			}

			if (( gFlags.anim3d ) && ( Screen == 1 ) && ( !EditModeTimer ))
			{
				anim3d( 0 );
			}

			if ( Screen == 60 )
			{
				AnimateScreenSaver();
			}

			if ( gFlags.firing )
			{
				if ( gFlags.read_bir && ( FireDuration > 10 ) )
				{
					ReadInternalResistance();
				}

				if ( PreheatTimer && !--PreheatTimer )
				{
					uint16_t pwr;

					if ( dfMode == 6 )
					{
						pwr = dfSavedCfgPwr[ConfigIndex];
					}
					else
					{
						pwr = dfPower;
					}

					if ( pwr > BatteryMaxPwr )
					{
						gFlags.limit_power = 1;
						PowerScale = 100 * BatteryMaxPwr / pwr;
					}
					else
					{
						gFlags.limit_power = 0;
						PowerScale = 100;
					}
				}
			}

			if ( KeyTicks >= 5 )
			{
				KeyRepeat();
			}

			GetUserInput();
		}

		if ( gFlags.tick_10hz )
		{
			// 10Hz
			gFlags.tick_10hz = 0;

			DataFlashUpdateTick();
			LEDTimerTick();

			if ( gFlags.firing )
			{
				++FireDuration;

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}

			if ( ShowWeakBatFlag )
				--ShowWeakBatFlag;

			if ( ShowProfNum )
				--ShowProfNum;

			if ( !( gFlags.firing && ISMODETC(dfMode) ) )
			{
				DrawScreen();
			}

			if ( KeyTicks < 5 )
			{
				KeyRepeat();
			}
		}

		if ( gFlags.tick_5hz )
		{
			// 5Hz
			gFlags.tick_5hz = 0;

			if ( !gFlags.rtcinit && NumBatteries )
			{
				InitRTC();
			}

			if ( gFlags.firing )
			{
				if ( TargetVolts == 0 )
				{
					ProbeAtomizer();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount < 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}
			}

			if ( IsClockOnScreen() )
			{
				static uint8_t u8Seconds = 61;
				S_RTC_TIME_DATA_T rtd;

				GetRTC( &rtd );

				if ( (uint8_t)rtd.u32Second != u8Seconds )
				{
					u8Seconds = (uint8_t)rtd.u32Second;
					gFlags.refresh_display = 1;
				}
			}
		}

		if ( gFlags.tick_2hz )
		{
			// 2Hz
			gFlags.tick_2hz = 0;

			gFlags.osc_1hz ^= 1;

			if ( gFlags.firing )
			{
				if ( ISMODETC(dfMode) )
				{
					DrawScreen();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount >= 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}
		}

		if ( gFlags.tick_1hz )
		{
			// 1Hz
			gFlags.tick_1hz = 0;

			if ( SplashTimer )
			{
				--SplashTimer;
				
				if ( !SplashTimer )
				{
					MainView();
				}
			}

			if ( !gFlags.firing && !dfStatus.off && !EditModeTimer )
			{
				if ( HideLogo )
				{
					if ( Screen == 1 )
					{
						--HideLogo;

						if ( !HideLogo )
						{
							gFlags.refresh_display = 1;
						}
					}
				}
			}
		}

		EventHandler();

	}
}
Пример #13
0
function Init() {
	/* Global colors.  May move them elsehwere in the future.
	 */

	LoadTheme("Default.txt");

	/* Uncomment to use US english day/month strings instead of whatever Windows
	 * is configured to use.
	 */
	// SetLocale(0x0409, 1);

	/* Enable low-level communication with the G15.  Makes playing with lights faster,
	 * allows V1/V2 differentiation, enables display when LCDMon.exe is not running,
	 * allows g- and m-key handling, etc.  Does not break compatibility when LCDMon is
	 * running.
	 */
	G15EnableHID();

	/* Will steal LCD when started.  Remove/comment out line to change that.
	 * Was added in the hope that it would cause the G19 to display LCD Miscellany instead
	 * of the app list.  Unfortunately, doesn't do that.  Note that this will make the first
	 * update only high priority.  Will return to normal afterwards.
	 */
	G15SetPriority(LGLCD_PRIORITY_ALERT);
	eventHandler = EventHandler();

	/* Change order (or comment out) to change order of views (or hide them)
	 */
	menuHandler = MenuHandler(eventHandler,
		DualView (
			StatusView(
				//DefaultStatus(),
				QuadStatus(),
				GameStatus(),
				// Sample screen with speedfan info.  Useful for figuring out which
				// number is what.
				// SpeedFanStatus(),
			),
			StatusView(
				G19Status(),
			)
		),

		// Change 0 to 1 to disable stealing non-media keys when focused.
		TaskManager(0),

		MediaView(
			MPCController(),
			VLCController(),
			WinampController(),
			ItunesController(),
			// Really, really slow, probably because of DDE.
			// AMIPController(),
		),

		TextEditorView(),

		ClipboardView(),

		CalculatorView(),

		// Specify urls like the next line, or modify ini:
		// RSSView(RSS_DISPLAY_TITLE | RSS_DISPLAY_DESCRIPTION,RSS_DISPLAY_TITLE | RSS_DISPLAY_DESCRIPTION,"http://news.google.com/?rss=&output=rss"),

		RSSView(
			RSS_DISPLAY_TITLE | RSS_DISPLAY_DESCRIPTION, // Channel title flags
			RSS_DISPLAY_TITLE | RSS_DISPLAY_DESCRIPTION, // Item text flags
			, // URL to use.  Can either be a string or a list of strings.  If left null, uses one in ini.
			 // Channels to display.  Currently, can only specify one per entry in previous parameter.
		),

		// uTorrent.
		DownloadView(),

		// Note:  SABnzbdView works fine, but is currently only formatted for G15s.
		// Delete the first "/*" to show it.

		// SABnzbdView 0.1.9 by 4wd:
		// Parameters are: SABnzbdView(URL, header, subview),
		// Where: URL = "http://ip:port/sabnzbd/"
		//     header = 0 if you want the TIME/DATE header
		//              1 if you want IP:Port header
		//    subview = 0 if not using StatusView for multiple views
		//              1 if using StatusView (allows Pause/Resume/Stop)
		//
		// For SABnzbd+ 0.4.9 or higher the URL must be:
		//        URL = "http://ip:port/sabnzbd/api?apikey=<insert key>"
		//
		// If you are only interested in one SABnzbd+ daemon, you can leave the
		// URL empty and place it in the LCDMisc.ini under [URLs].  See the example.
		/* SABnzbdView(, 0, 0), //*/

		// The sample below shows using StatusView to monitor more than one SABnzbd+
		// Switching between screens is done by pressing the LCDMisc 'OK' button,
		// (third LCD button).  URL is required when using StatusView.
		// You can mix URLs for SABnzbd+ versions.
		/*
			StatusView("Images\SABnzbd.png",
			  SABnzbdView("http://1.2.3.4:8080/sabnzbd/",1, 1),
			  SABnzbdView("http://5.6.7.8:8080/sabnzbd/api?apikey=77e45017",1, 1)
			),
		*/




		/* Parameters aren't needed, but replace the 0 with a 1 to display location
		 * instead of time at the top, over the header (Small LCDs only).  No room for both,
		 * unfortunately.  Could squeeze the location and either the date or time on
		 * together for most location names, but not all, so sticking with either-or
		 * for now.
		 */
		WeatherView(,0),

		// Sample showing how to use a StatusView to let you switch between
		// weather screens.  Note that the first is in Fahrenheit and second
		// is in Celsuis.  Just uncomment (Delete  the "/*") and change/add
		// urls as needed.
		/*
		StatusView(
			WeatherView("http://xml.weather.yahoo.com/forecastrss?p=usma0066&u=f", 1),
			WeatherView("http://xml.weather.yahoo.com/forecastrss?p=CAXX0487&u=c", 1)
		),
		//*/
	);

	// Turn off lights during screensaver.  Delete the "//" to enable.
	// ScreenSaverLightToggle(eventHandler);

	/* Smoothes out system volume changes.  Note that it doesn't steal the
	 * volume wheel.  Instead, it monitors the system volume setting.
	 * It will partially break the Windows Master volume slider.
	 * Intended to rectify the default ~4% adjustment per tick of the
	 * volume wheel, which is much too coarse if you use a lower setting.
	 * Experimental, breaks dragging on master volume control.  Vista
	 * already uses smaller increments, so not useful there.
	 */
	//VolumeSmoother(eventHandler);

	// Tray icons.  Uncomment whichever ones you like.
	//AddCpuIcon();
	//AddTotalCpuIcon();
	//AddNetIcon();
}
Пример #14
0
	IntroduccionEscena::IntroduccionEscena() {
		onTimerTick = gcnew EventHandler(this, &IntroduccionEscena::timerTick);
		onKeyDown = gcnew KeyEventHandler(this, &IntroduccionEscena::teclaDown);
	}
Пример #15
0
/*
 * @function main
 */
int main( int argc, const char** argv ) {

  // Get the mode
  if (argc > 1)
  {
    const char *inputMode = argv[1];
    if (strcmp(inputMode, "normal") == 0) {
      mode = NORMAL;
    } else if (strcmp(inputMode, "debug") == 0) {
      mode = DEBUG;
    } else if (strcmp(inputMode, "plot") == 0) {
      mode = PLOT;
    } else {
      mode = NORMAL;
    }
  }
  else
  {
    mode = NORMAL;
  }

  if (mode == NORMAL) {
    eventHandler = EventHandler();
  }

  if (mode == DEBUG || mode == NORMAL) {
    printf("Input Mode: %s\n", mode == NORMAL ? "normal" :
        mode == DEBUG ? "debug" :
        mode == PLOT ? "plot" : "none");

    cv::namedWindow(main_window_name,CV_WINDOW_NORMAL);
    cv::moveWindow(main_window_name, 400, 100);
    cv::namedWindow(face_window_name,CV_WINDOW_NORMAL);
    cv::moveWindow(face_window_name, 10, 100);
    cv::namedWindow("Right Eye",CV_WINDOW_NORMAL);
    cv::moveWindow("Right Eye", 10, 600);
    cv::namedWindow("Left Eye",CV_WINDOW_NORMAL);
    cv::moveWindow("Left Eye", 10, 800);
  } else if (mode == PLOT) {
    cv::namedWindow(face_window_name,CV_WINDOW_NORMAL);
    cv::moveWindow(face_window_name, 400, 100);
  }

  cv::Mat frame;

  // Load the cascades
  if( !face_cascade.load( FACE_CASCADE_FILE ) ){ printf("--(!)Error loading face cascade, please change face_cascade_name in source code.\n"); return -1; };


  // Read the video stream
  cv::VideoCapture capture( 0 );
  if( capture.isOpened() ) {
    capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
    capture.set(CV_CAP_PROP_FPS, 15);
    capture >> frame;
    while( true ) {
      capture >> frame;

      // mirror it
      cv::flip(frame, frame, 1);
      frame.copyTo(debugImage);

      // Apply the classifier to the frame
      if( !frame.empty() ) {
        detectAndDisplay( frame );
      }
      else {
        printf(" --(!) No captured frame -- Break!");
        break;
      }
      if (mode == DEBUG || mode == NORMAL) {
        imshow(main_window_name, debugImage);
      }

      if (mode == DEBUG || mode == PLOT || mode == NORMAL) {
        int c = cv::waitKey(10);
        if( (char)c == 'c' ) { break; }
        if( (char)c == 'f' ) {
          imwrite("frame.png", frame);
        }
      }
    }
  }
Пример #16
0
bool xmpp_dummy::Handler(IMEvent* event) {
	if (EventHandler()) {
		return EventHandler()->Handler(event);
	}
	return IMEventHandler::Handler(event);
}
Пример #17
0
int main(int argc, char *argv[]) {

	time_t newStart, newEnd;
	time(&newStart);
//	double first, second;
//	first = CPU_TIME;
//	clock_t start = clock();

	setbuf(stdout, NULL); // debugguing mode

	event *eventList, *ptrAuxList, *ptrLastNode;
	machine *machineList, *ptrAuxMachine;
	task *taskList, *orderedTaskList;
	job *jobList;
	taskAccountInfo *taskAccountInfoList;
	gridAccountInfo *gridInfoList;
	jobAccountInfo *jobAccountInfoList;
	balanceAccountInfo *balanceAccountInfoList;
	schedule *scheduleList;

	unsigned long int count = 0;
	unsigned long int totalNumberOfEvents = 0;
	gridMachinesID = 0; scheduleID = 0;
	aggregatedUtility = 0; aggregatedCost =0; aggregatedProfit = 0;
//	balanceCredit = 0;

//	unsigned long int totalUtility = 0;
//	float totalCost = 0.0, totalProfit = 0.0;

	if (argc == 14) {

		optFlag = (atoi(argv[1]));
		simulationTime = ((atoi(argv[2]) * 24 * 60) + 1440); // simulationTime is a global variable (minutes) based on the input parameter (days)
		jobSize = (atoi(argv[3]));
		gridQoSFactor = (atof(argv[4]));
		ondemandPriceFactor = (atof(argv[5]));
		inhouseFactor = (atof(argv[6]));
		numberOfLocalMachines = (atoi(argv[7]));
		numberOfReservedMachines = atoi(argv[8]);
		numberOfOnDemandMachines = atoi(argv[9]);
		if (atoi(argv[10]) == 0) {
			taskAvgTime = 10;
			taskSdvTime = 5;
		} else {
			taskAvgTime = 47;
			taskSdvTime = 26;
		}
		gridAvgUptime = (atoi(argv[11]));
		utilityFunction = (atoi(argv[12]));
		simSeed = (atoi(argv[13]));

		ondemandUsagePrice = (0.08*ondemandPriceFactor); reservedUsagePrice = 0.064; reservationPrice = 124.00;
		reservationPricePerDay = (numberOfReservedMachines * reservationPrice)/365;

		srand(simSeed);

		// starting a new event list
		if ( (eventList = malloc(sizeof(event))) ) {
			// start simulation event
			eventList->eventNumber = 0; eventList->eventID = 0; eventList->time = 0; eventList->flag = -1; eventList->nextEvent = NULL;
		} else printf("ERROR (main simulator): merdou o malloc!!!\n");

		// finish simulation event
		if ( (ptrLastNode = malloc(sizeof(event))) ) {
			ptrLastNode->eventNumber = 1; ptrLastNode->eventID = SIMFINNISHED; ptrLastNode->time = (simulationTime+1); ptrLastNode->flag = -1; ptrLastNode->nextEvent = NULL;
		} else printf("ERROR (main simulator): merdou o malloc!!!\n");

		eventList->nextEvent = ptrLastNode;
		ptrThisEvent = eventList;

		// filling the event list with local and grid (???) machines, and workload jobs and tasks
		FillEmptyEventList(eventList);

		// IMPLEMENTAR AS VARIANTES PARA O FILLEMPTYEVENTLIST();
		//	ptrAuxAux = eventList;
		//	int count1 = 0;
		//	while(ptrAuxAux) {
		//		count1++;
		//		if (ptrAuxAux->eventID == 1 || ptrAuxAux->eventID == 2) {
		//			printf("eventID %d time %d machineID %d source %d status %d AT %d DT %d UP %.2f RP %.2f\n", ptrAuxAux->eventID, ptrAuxAux->time, ptrAuxAux->machineInfo.machineID,
		//					ptrAuxAux->machineInfo.source, ptrAuxAux->machineInfo.status, ptrAuxAux->machineInfo.arrivalTime, ptrAuxAux->machineInfo.departureTime,
		//					ptrAuxAux->machineInfo.usagePrice, ptrAuxAux->machineInfo.reservationPrice);
		//		}
		//		ptrAuxAux = ptrAuxAux->nextEvent;
		//	}
		//	printf("a lista tem %d eventos\n", count1);
		//	printf("\n");

		// starting a machine list
		if ( (machineList = malloc(sizeof(machine))) ) {
			machineList->machineID = 0;		// 0 means code for an empty machine list
			machineList->nextMachine = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting a task list
		if ( (taskList = malloc(sizeof(task))) ) {
			taskList->taskID = 0;			// 0 means code for an empty task list
			taskList->nextTask = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting an ordered task list
		if ( (orderedTaskList = malloc(sizeof(task))) ) {
			orderedTaskList->taskID = 0;			// 0 means code for an empty task list
			orderedTaskList->nextTask = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting a job list
		if ( (jobList = malloc(sizeof(job))) ) {
			jobList->jobID = 0;			// 0 means code for an empty job list
			jobList->nextJob = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting an account list to register the execution of tasks
		if ( (taskAccountInfoList = malloc(sizeof(taskAccountInfo))) ) {
			taskAccountInfoList->taskAccountID = 0;			// 0 means code for an empty task list
			taskAccountInfoList->status = ACCOUNTUNFINNISHED;
			taskAccountInfoList->nextTaskAccountInfo = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting an account list to register the execution of jobs
		if ( (jobAccountInfoList = malloc(sizeof(jobAccountInfo))) ) {
			jobAccountInfoList->jobAccountID = 0;			// 0 means code for an empty task list
			jobAccountInfoList->nextJobAccountInfo = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting an account list to register the donations to the grid
		if ( (gridInfoList = malloc(sizeof(gridAccountInfo))) ) {
			gridInfoList->gridAccountID = 0;			// 0 means code for an empty task list
			gridInfoList->nextGridAccountInfo = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting a balance account list
		if ( (balanceAccountInfoList = malloc(sizeof(balanceAccountInfo))) ) {
			balanceAccountInfoList->balanceAccountID = 0;
			balanceAccountInfoList->time = 0;
			balanceAccountInfoList->value = 0;
			balanceAccountInfoList->nextBalanceAccountInfo = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		// starting a schedule list
		if ( (scheduleList = malloc(sizeof(schedule))) ) {
			scheduleList->scheduleID = 0;
			scheduleList->nextSchedule = NULL;
		}
		else {
			printf("ERROR (main simulator): merdou o malloc!!!\n");
		}

		ptrLastBalance = balanceAccountInfoList;
		ptrAuxList = eventList;
		long int lastEventNumber = -1;
		unsigned long int lastEventTime = 0;
		unsigned long int numberOfArrivals = 0, numberOfDepartures = 0;
		//	int count = 0;
		while(ptrAuxList) {

//			if(ptrAuxList->time > (simulationTime + 1)) break;
			ptrThisEvent = ptrAuxList;

//			printf("event# %d eventID %d ", ptrAuxList->eventNumber, ptrAuxList->eventID);
			printf("event# %ld ", ptrAuxList->eventNumber);


			switch (ptrAuxList->eventID) {
			case 0:
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 1:				// Machine Arrival
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 2:				// Machine Departure
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 3:				// Grid Donating
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 4:				// Grid Preempted
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 5:				// Task Arrival
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 6:				// Task Schedule
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 7:				// Task Preempted
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 8:				// Task Finnished
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 9:				// Job Arrival
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 10:			// Job Started
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 11:			// Job Finnished
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 12:			// Allocation Planning
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			case 13:			// Simulation Finnished
				EventHandler(ptrAuxList, &eventList, &machineList, &taskList, &taskAccountInfoList, gridInfoList, jobList, jobAccountInfoList,
						&balanceAccountInfoList, &orderedTaskList, scheduleList);
				break;
			default:
				printf("unkwonk event!!!\n");
				break;
			}

			// ##### INVARIANTES PARA A LISTA DE EVENTOS #####
			totalNumberOfEvents++;

			// testar se o atual eh o anterior - 1
			if ( (ptrAuxList->eventNumber - 1) != lastEventNumber ) {
				//			printf("\n");
				printf("(INVARIANTES) NUMERACAO DOS EVENTOS ESTA ERRADA!!!\n");
				break;
			}
			lastEventNumber = ptrAuxList->eventNumber;

			// testas se o tempo estah crescente
			if (ptrAuxList->time < lastEventTime) {
				//			printf("\n");
				printf("(INVARIANTES) EVENTOS NAO ESTAO EM ORDEM DECRESCENTE!!!\n");
				break;
			}
			lastEventTime = ptrAuxList->time;

			// testar se o numero de chegadas de maquinas eh igual ao de partida
			if (ptrAuxList->eventID == MACHARRIVAL) numberOfArrivals++;
			if (ptrAuxList->eventID == MACHDEPARTURE) numberOfDepartures++;

			// atualizar o ponteiro para lista de eventos e remover o noh anterior

			event *ptrLastEvent;
			ptrLastEvent = ptrAuxList;
			ptrAuxList = ptrAuxList->nextEvent; // passa pro proximo evento

			if ( ptrAuxList != NULL && (ptrAuxList->time > ptrLastEvent->time) ) {

				event *ptrAuxEvent;
				ptrAuxEvent = eventList;
				eventList = ptrAuxList;
				while(ptrAuxEvent != ptrLastEvent) {
					event *ptrRemove;
					ptrRemove = ptrAuxEvent;
					ptrAuxEvent = ptrAuxEvent->nextEvent;
					free(ptrRemove);
					ptrRemove = NULL;
				}
				if (ptrAuxEvent == ptrLastEvent) {
					free(ptrLastEvent);
					ptrLastEvent = NULL;
					ptrAuxEvent = NULL;
				}

			}

		} // end of while(ptrAuxList)
		//	printf("\n");

		// testando a numeracao de eventos
		if ( totalNumberOfEvents != (lastEventNumber+1) ) {
			//		printf("\n");
			printf("(INVARIANTES) NUMERO ERRADO DE EVENTOS!!!\n");
			//		printf("\n");
		}

		// testando o numero de chegadas e partidas de maquinas
		if (numberOfArrivals != numberOfDepartures) {
			//		printf("\n");
			printf("(INVARIANTES) NUMERO DE CHEGADAS DIFERENTE DO NUMERO DE SAIDAS!!!\n");
		}
		// ##### FIM DAS INVARIANTES PARA A LISTA DE EVENTOS #####


		// CIRAR UM TESTE DEPOIS PARA SABER SE TODAS AS TASKS FORAM EXECUTADAS OU NAO

//		FILE *ptrFileJobAccountInfo;
//		ptrFileJobAccountInfo = fopen("jobaccountinfo.txt", "a+");
//		jobAccountInfo *ptrAuxJobAccountInfo;
//		ptrAuxJobAccountInfo = jobAccountInfoList;
//		count = 0;
//		while(ptrAuxJobAccountInfo) {
//			count++;
//			fprintf(ptrFileJobAccountInfo, "jobAccountID %d jobID %d ST %ld FT %ld\n", ptrAuxJobAccountInfo->jobAccountID, ptrAuxJobAccountInfo->jobID, ptrAuxJobAccountInfo->startTime, ptrAuxJobAccountInfo->finnishTime);
//			ptrAuxJobAccountInfo = ptrAuxJobAccountInfo->nextJobAccountInfo;
//		}
//		//	printf("a lista de jobs tem %d registros\n", count);
//		//	printf("\n");
//		fclose(ptrFileJobAccountInfo);

//		FILE *ptrFileJobList;
//		ptrFileJobList = fopen("joblist.txt", "a+");
//		job *ptrAuxJob;
//		ptrAuxJob = jobList;
//		count = 0;
//		while(ptrAuxJob) {
//			count++;
//			totalCost += ptrAuxJob->cost;
//			totalUtility += ptrAuxJob->utility;
//			totalProfit += (ptrAuxJob->utility - ptrAuxJob->cost);
//			fprintf(ptrFileJobList, "jobID %d jobSize %d AR %ld FT %ld LT %d DL %ld MU %ld Utility %ld Cost %.2f Profit %.2f\n", ptrAuxJob->jobID, ptrAuxJob->jobSize, ptrAuxJob->arrivalTime, ptrAuxJob->finnishTime, ptrAuxJob->longestTask,
//					ptrAuxJob->deadline, ptrAuxJob->maxUtility, ptrAuxJob->utility, ptrAuxJob->cost, (ptrAuxJob->utility - ptrAuxJob->cost));
//			ptrAuxJob = ptrAuxJob->nextJob;
//		}
//		//	printf("\n");
//		fclose(ptrFileJobList);

//		FILE *ptrFileTaskList;
//		ptrFileTaskList = fopen("tasklist.txt", "a+");
//		task *ptrAuxTask;
//		ptrAuxTask = taskList;
//		count = 0;
//		while(ptrAuxTask) {
//			count++;
//			fprintf(ptrFileTaskList, "taskID %d jobID %d jobSize %d AR %ld RT %d status %d submissions %d\n", ptrAuxTask->taskID, ptrAuxTask->jobID, ptrAuxTask->jobSize,
//					ptrAuxTask->arrivalTime, ptrAuxTask->runtime, ptrAuxTask->status, ptrAuxTask->numberOfSubmissions);
//			ptrAuxTask = ptrAuxTask->nextTask;
//		}
//		//	printf("\n");

//		task *ptrAuxOrderedTask;
//		ptrAuxOrderedTask = orderedTaskList;
//		count = 0;
//		while(ptrAuxOrderedTask) {
//			count++;
//			fprintf(ptrFileTaskList, "taskID %d jobID %d jobSize %d AR %ld RT %d status %d submissions %d\n", ptrAuxOrderedTask->taskID, ptrAuxOrderedTask->jobID, ptrAuxOrderedTask->jobSize,
//					ptrAuxOrderedTask->arrivalTime, ptrAuxOrderedTask->runtime, ptrAuxOrderedTask->status, ptrAuxOrderedTask->numberOfSubmissions);
//			ptrAuxOrderedTask = ptrAuxOrderedTask->nextTask;
//		}
//		//	printf("\n");
//		fclose(ptrFileTaskList);

//		FILE *ptrFileScheduleList;
//		ptrFileScheduleList = fopen("schedulelist.txt", "a+");
//		schedule *ptrAuxSchedule;
//		ptrAuxSchedule = scheduleList;
//		while(ptrAuxSchedule) {
//			fprintf(ptrFileScheduleList, "scheduleID %d scheduleTime %d machineID %d source %d taskID %d jobID %d RT %d\n", ptrAuxSchedule->scheduleID, ptrAuxSchedule->scheduleTime, ptrAuxSchedule->machineID,
//					ptrAuxSchedule->source, ptrAuxSchedule->taskID, ptrAuxSchedule->jobID, ptrAuxSchedule->runtime);
//			ptrAuxSchedule = ptrAuxSchedule->nextSchedule;
//		}
//		fclose(ptrFileScheduleList);

//		// ##### INVARIANTES PARA A LISTA DE EVENTOS #####
//		event *ptrAuxEventList;
//		ptrAuxEventList = eventList;
//		int lastEventNumber = -1;
//		unsigned int lastEventTime = 0;
//		unsigned short int numberOfArrivals = 0, numberOfDepartures = 0;
//		while(ptrAuxEventList) {
//			totalNumberOfEvents++;
//
//			// testar se o atual eh o anterior - 1
//			if ( (ptrAuxEventList->eventNumber - 1) != lastEventNumber ) {
//				//			printf("\n");
//				printf("(INVARIANTES) NUMERACAO DOS EVENTOS ESTA ERRADA!!!\n");
//				break;
//			}
//			lastEventNumber = ptrAuxEventList->eventNumber;
//
//			// testas se o tempo estah crescente
//			if (ptrAuxEventList->time < lastEventTime) {
//				//			printf("\n");
//				printf("(INVARIANTES) EVENTOS NAO ESTAO EM ORDEM DECRESCENTE!!!\n");
//				break;
//			}
//
//			// testar se o numero de chegadas de maquinas eh igual ao de partida
//			if (ptrAuxEventList->eventID == MACHARRIVAL) numberOfArrivals++;
//			if (ptrAuxEventList->eventID == MACHDEPARTURE) numberOfDepartures++;
//
//			ptrAuxEventList = ptrAuxEventList->nextEvent;
//
//		}
//
//		// testando a numeracao de eventos
//		if ( totalNumberOfEvents != (ptrLastNode->eventNumber+1) || lastEventNumber != ptrLastNode->eventNumber ) {
//			//		printf("\n");
//			printf("(INVARIANTES) NUMERO ERRADO DE EVENTOS!!!\n");
//			//		printf("\n");
//		}
//
//		// testando o numero de chegadas e partidas de maquinas
//		if (numberOfArrivals != numberOfDepartures) {
//			//		printf("\n");
//			printf("(INVARIANTES) NUMERO DE CHEGADAS DIFERENTE DO NUMERO DE SAIDAS!!!\n");
//		}
//		// ##### FIM DAS INVARIANTES PARA A LISTA DE EVENTOS #####

		// ##### INVARIANTES PARA A LISTA DE MAQUINAS (CHEGADAS E PARTIDAS) #####
		ptrAuxMachine = machineList;
		if (ptrAuxMachine != NULL) {

			printf("\n");
			printf("(INVARIANTES) LISTA NAO VAZIA DE MAQUINAS!!!\n");

			count = 0;
			while(ptrAuxMachine) {
				count++;
				printf("machineID %d source %d status %d AT %ld DT %ld UP %.2f RP %.2f\n", ptrAuxMachine->machineID,
						ptrAuxMachine->source, ptrAuxMachine->status, ptrAuxMachine->arrivalTime, ptrAuxMachine->departureTime,
						ptrAuxMachine->usagePrice, ptrAuxMachine->reservationPrice);
				ptrAuxMachine = ptrAuxMachine->nextMachine;
			}
			printf("a lista tem %ld maquinas\n", count);
			printf("\n");

		}
		// ##### FIM INVARIANTES PARA A LISTA DE MAQUINAS (CHEGADAS E PARTIDAS) #####

//		// ##### INVARIANTES PARA A LISTA DE EXECUCAO DAS TASKS #####
//		FILE *ptrFileTaskAccountInfo;
//		ptrFileTaskAccountInfo = fopen("taskaccountinfo.txt", "a+");
//		taskAccountInfo *ptrAuxTaskAccountInfo;
//		ptrAuxTaskAccountInfo = taskAccountInfoList;
//		unsigned long int totalExecutionTime = 0;
//		while(ptrAuxTaskAccountInfo) {
//
//			if (ptrAuxTaskAccountInfo->source == 1) {
//				totalExecutionTime += (ptrAuxTaskAccountInfo->finnishTime-ptrAuxTaskAccountInfo->startTime);
//			}
//			if ( ptrAuxTaskAccountInfo->runtime < (ptrAuxTaskAccountInfo->finnishTime-ptrAuxTaskAccountInfo->startTime) ) {
//				//			printf("\n");
//				printf("(INVARIANTES) TEMPO DE EXECUCAO MAIOR DO QUE O RUNTIME!!!\n");
//			}
//
//			if ( (ptrAuxTaskAccountInfo->finnishTime-ptrAuxTaskAccountInfo->startTime) < 0 ) {
//				//			printf("\n");
//				printf("(INVARIANTES) FINNISHTIME MENOR DO QUE STARTTIME!!!\n");
//			}
//
//					fprintf(ptrFileTaskAccountInfo,"taskAccountID %d machineID %d source %d taskID %d jobID %d RT %d ET %ld ST %ld FT %ld Status %d Cost %.2f\n", ptrAuxTaskAccountInfo->taskAccountID,
//							ptrAuxTaskAccountInfo->machineID, ptrAuxTaskAccountInfo->source, ptrAuxTaskAccountInfo->taskID, ptrAuxTaskAccountInfo->jobID,
//							ptrAuxTaskAccountInfo->runtime, (ptrAuxTaskAccountInfo->finnishTime-ptrAuxTaskAccountInfo->startTime),
//							ptrAuxTaskAccountInfo->startTime, ptrAuxTaskAccountInfo->finnishTime, ptrAuxTaskAccountInfo->status, ptrAuxTaskAccountInfo->cost);
//
//			ptrAuxTaskAccountInfo = ptrAuxTaskAccountInfo->nextTaskAccountInfo;
//		}
//		//	printf("a lista tem %d tasks\n", count);
//		//	printf("\n");
//		fclose(ptrFileTaskAccountInfo);
//		// ##### FIM INVARIANTES PARA A LISTA DE EXECUCAO DAS TASKS #####

//		// ##### INVARIANTES PARA O CONSUMO DA GRADE E PARA BALANCO DE CREDITOS #####
//		FILE *ptrFileGridAccountInfo;
//		ptrFileGridAccountInfo = fopen("gridaccountinfo.txt", "a+");
//		gridAccountInfo *ptrAuxGridInfo;
//		ptrAuxGridInfo = gridInfoList;
//		unsigned long int credit = 0;
//		while(ptrAuxGridInfo) {
//			credit += (ptrAuxGridInfo->finnishTime - ptrAuxGridInfo->startTime);
//					fprintf(ptrFileGridAccountInfo, "gridAccountID %d machineID %d source %d ST %ld FT %ld\n", ptrAuxGridInfo->gridAccountID,
//							ptrAuxGridInfo->machineID, ptrAuxGridInfo->source, ptrAuxGridInfo->startTime,
//							ptrAuxGridInfo->finnishTime);
//			ptrAuxGridInfo = ptrAuxGridInfo->nextGridAccountInfo;
//		}
//		//	printf("a lista tem %d balances, e o total de creditos doados e %d\n", count, credit);
//		//	printf("\n");
//		fclose(ptrFileGridAccountInfo);
//
//		FILE *ptrFileBalanceAccountInfo;
//		ptrFileBalanceAccountInfo = fopen("balanceaccountinfo.txt", "a+");
//		balanceAccountInfo *ptrAuxBalanceAccountInfo;
//		ptrAuxBalanceAccountInfo = balanceAccountInfoList;
//		unsigned long int consumed = 0, lastValue = 0;
//		while(ptrAuxBalanceAccountInfo->nextBalanceAccountInfo != NULL) {
//
//			if (ptrAuxBalanceAccountInfo->consumed > lastValue) {
//				consumed += lastValue;
//			}
//			else {
//				consumed += ptrAuxBalanceAccountInfo->consumed;
//			}
//			lastValue = ptrAuxBalanceAccountInfo->value;
//
//			fprintf(ptrFileBalanceAccountInfo, "balanceAccountID %ld time %ld consumed %ld value %ld\n", ptrAuxBalanceAccountInfo->balanceAccountID,
//					ptrAuxBalanceAccountInfo->time, ptrAuxBalanceAccountInfo->consumed, ptrAuxBalanceAccountInfo->value);
//
//			ptrAuxBalanceAccountInfo = ptrAuxBalanceAccountInfo->nextBalanceAccountInfo;
//
//		}
//		consumed += ptrAuxBalanceAccountInfo->consumed;
//		fprintf(ptrFileBalanceAccountInfo, "balanceAccountID %ld time %ld consumed %ld value %ld\n", ptrAuxBalanceAccountInfo->balanceAccountID, ptrAuxBalanceAccountInfo->time,
//				ptrAuxBalanceAccountInfo->consumed, ptrAuxBalanceAccountInfo->value);
//		//	printf("a lista de balances tem %d registros\n", count);
//		//	printf("\n");
//		fclose(ptrFileBalanceAccountInfo);
//
//		if ( credit != (ptrAuxBalanceAccountInfo->value + consumed) ) {
//			//		printf("\n");
//			printf("(INVARIANTES) BALANCE DO GRID ERRADO!!!\n");
//			printf("credit %ld (balance+consumed) %ld consumed %ld totalET %ld\n", credit, (ptrAuxBalanceAccountInfo->value + consumed), consumed, totalExecutionTime);
//		}
//		//	printf("doado %d consumido %d balance %d\n", credit, consumed, ptrAuxBalanceAccountInfo->value);
//		// ##### FIM INVARIANTES PARA O CONSUMO DA GRADE E PARA BALANCO DE CREDITOS #####

	} else printf("ERROR (Main Simulator): invalid number of input parameters!!!\n");

	time(&newEnd);
//   second = CPU_TIME;

//	printf("Opt Flag: %d Grid QoS-Factor: %.2f Simulation Period (days): %d Machines ([InH, Res, OnD]): [%d, %d, %d] Seed: %d UF: %d Time elapsed (seconds): %ld\n",
//			optFlag, gridQoSFactor, (int)(simulationTime/1440), numberOfLocalMachines, numberOfReservedMachines, numberOfOnDemandMachines,
//			simSeed, utilityFunction,(clock() - start) / CLOCKS_PER_SEC);

	printf("SimMode: %d SimTime (days): %d JobSize: %d GridQoS: %.2f OnDPFactor: %.2f IhFactor: %.2f Machines ([InH, Res, OnD]): [%d, %d, %d] TaskAvg: %d "
			"GridAvg: %d UF: %d Seed: %d #Events: %ld ExecTime (seconds): %ld AggUtility: %.2f AggCost %.2f AggProfit %.2f\n", optFlag, (int)(simulationTime/1440), jobSize, gridQoSFactor, ondemandPriceFactor,
			inhouseFactor, numberOfLocalMachines, numberOfReservedMachines, numberOfOnDemandMachines, taskAvgTime, gridAvgUptime, utilityFunction, simSeed,
			totalNumberOfEvents, (unsigned long int)(newEnd - newStart), aggregatedUtility, aggregatedCost, aggregatedProfit);

//	event teste;
//	printf("tamanho das estruturas: %d\n", sizeof(teste));

	return EXIT_SUCCESS;
}