Example #1
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	Game game;
	init(&game);
	srand(time(NULL));
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	int done=0;
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			done = check_keys(&e);
		}
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		while (physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	logClose();
	return 0;
}
Example #2
0
BOOL COXProcess::GetExitTime(COleDateTime& oleTime) const
{
	FILETIME creationTime;
	if(!GetExitTime(creationTime))
		return FALSE;

	COleDateTime timeCopy(creationTime);
	oleTime=timeCopy;

	return TRUE;
}
Example #3
0
BOOL COXProcess::GetCreationTime(CTime& time) const
{
	FILETIME creationTime;
	if(!GetCreationTime(creationTime))
		return FALSE;

	CTime timeCopy(creationTime);
	time=timeCopy;

	return TRUE;
}
Example #4
0
int main(void)
{
        int done=0;
        srand(time(NULL));
        initXWindows();
        init_opengl();
        //declare game object
        Game game;
        game.n=0;
	
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);

        //declare a box shape
	for(int i = 0; i<5; i++)
	{
        	game.box[i].width = 100;
        	game.box[i].height = 15;
       		
		game.box[i].center.x = 120 + (60*i);
       		game.box[i].center.y = 500 - (100*i);
	}

	game.circle.radius = .5;
        game.circle.center.x = 60 + 9*65;
        game.circle.center.y = 450- 8*60;


        //start animation
        while(!done) {
                while(XPending(dpy)) {
                        XEvent e;
                        XNextEvent(dpy, &e);
                        check_mouse(&e, &game);
                        done = check_keys(&e, &game);
		}

		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		
		while(physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
                movement(&game);
                render(&game);
                glXSwapBuffers(dpy, win);
        }
        cleanupXWindows();
        return 0;
}
Example #5
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	init();
	init_sounds();
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			check_keys(&e);
		}
		//
		//Below is a process to apply physics at a consistent rate.
		//1. Get the time right now.
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		//2. How long since we were here last?
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		//3. Save the current time as our new starting time.
		timeCopy(&timeStart, &timeCurrent);
		//4. Add time-span to our countdown amount.
		physicsCountdown += timeSpan;
		//5. Has countdown gone beyond our physics rate? 
		//       if yes,
		//           In a loop...
		//              Apply physics
		//              Reducing countdown by physics-rate.
		//              Break when countdown < physics-rate.
		//       if no,
		//           Apply no physics this frame.
		while(physicsCountdown >= physicsRate) {
			//6. Apply physics
			physics();
			//7. Reduce the countdown by our physics-rate
			physicsCountdown -= physicsRate;
		}
		//Always render every frame.
		render();
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	#ifdef USE_SOUND
	fmod_cleanup();
	#endif //USE_SOUND
	logClose();
	return 0;
}
Example #6
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    init_sounds();

    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    //declare game object
    Game game;

    fmod_playsound(1);
    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_resize(&e);
	    check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	movementCountdown += timeSpan;
	while(movementCountdown >= movementRate)
	{
	    movement(&game);
	    movementCountdown -= movementRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    return 0;
}
int main(void)
{
    logOpen();
    initXWindows();
    init_opengl();
    init();
    //buttonsInit();------------------------------------------------------------------
    init_sounds();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_resize(&e);
            check_mouse(&e);
            GOcheck_mouse(&e);
            check_keys(&e);

        }
        clock_gettime(CLOCK_REALTIME, &timeCurrent);
        timeSpan = timeDiff(&timeStart, &timeCurrent);
        timeCopy(&timeStart, &timeCurrent);
        physicsCountdown += timeSpan;
        while(physicsCountdown >= physicsRate) {
            physics();
            physicsCountdown -= physicsRate;
        }
        render();
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    logClose();
    return 0;
}
Example #8
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    Game game;
    DefineRagdoll(&game);
    init_opengl(&game);
    create_sounds();
    play();
    //declare game object
    init_keys();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_mouse(&e, &game);
	    check_resize(&game, &e);
	    done = check_keys(&e);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	physicsCountdown += timeSpan;
	while(physicsCountdown >= physicsRate) {
	    movement(&game);
	    physicsCountdown -= physicsRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
Example #9
0
int main(void)
{
	initXWindows();
    srand(time(NULL));
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    init_opengl();
    init_ship();
	//Do this to allow fonts
	glEnable(GL_TEXTURE_2D);
	initialize_fonts();
	init_textures();
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			check_keys(&e);
		}
        clock_gettime(CLOCK_REALTIME, &timeCurrent);
        timeSpan = timeDiff(&timeStart, &timeCurrent);
        timeCopy(&timeStart, &timeCurrent);
        physicsCountdown += timeSpan;
        while (physicsCountdown >= physicsRate) {
            physics();
            physicsCountdown -= physicsRate;
            render();
        }
		//physics();
		//render();
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	return 0;
}
Example #10
0
void physics(Game *g)
{
	Flt d0,d1,dist;
	//Update ship position
	g->ship.pos[0] += g->ship.vel[0];
	g->ship.pos[1] += g->ship.vel[1];
	//Check for collision with window edges
	if (g->ship.pos[0] < 0.0) {
		g->ship.pos[0] += (float)xres;
	}
	else if (g->ship.pos[0] > (float)xres) {
		g->ship.pos[0] -= (float)xres;
	}
	else if (g->ship.pos[1] < 0.0) {
		g->ship.pos[1] += (float)yres;
	}
	else if (g->ship.pos[1] > (float)yres) {
		g->ship.pos[1] -= (float)yres;
	}
	//
	//
	//Update bullet positions
	struct timespec bt;
	clock_gettime(CLOCK_REALTIME, &bt);
	Bullet *b = g->bhead;
	while (b) {
		//How long has bullet been alive?
		double ts = timeDiff(&b->time, &bt);
		if (ts > 2.5) {
			//time to delete the bullet.
			Bullet *saveb = b->next;
			deleteBullet(g, b);
			b = saveb;
			g->nbullets--;
			continue;
		}
		//move the bullet
		b->pos[0] += b->vel[0];
		b->pos[1] += b->vel[1];
		//Check for collision with window edges
		if (b->pos[0] < 0.0) {
			b->pos[0] += (float)xres;
		}
		else if (b->pos[0] > (float)xres) {
			b->pos[0] -= (float)xres;
		}
		else if (b->pos[1] < 0.0) {
			b->pos[1] += (float)yres;
		}
		else if (b->pos[1] > (float)yres) {
			b->pos[1] -= (float)yres;
		}
		b = b->next;
	}
	//
	//Update asteroid positions
	Asteroid *a = g->ahead;
	while (a) {
		a->pos[0] += a->vel[0];
		a->pos[1] += a->vel[1];
		//Check for collision with window edges
		if (a->pos[0] < -100.0) {
			a->pos[0] += (float)xres+200;
		}
		else if (a->pos[0] > (float)xres+100) {
			a->pos[0] -= (float)xres+200;
		}
		else if (a->pos[1] < -100.0) {
			a->pos[1] += (float)yres+200;
		}
		else if (a->pos[1] > (float)yres+100) {
			a->pos[1] -= (float)yres+200;
		}
		a->angle += a->rotate;
		a = a->next;
	}
	//
	//Asteroid collision with bullets?
	//If collision detected:
	//     1. delete the bullet
	//     2. break the asteroid into pieces
	//        if asteroid small, delete it
	a = g->ahead;
	while (a) {
		//is there a bullet within its radius?
		Bullet *b = g->bhead;
		while (b) {
			d0 = b->pos[0] - a->pos[0];
			d1 = b->pos[1] - a->pos[1];
			dist = (d0*d0 + d1*d1);
			if (dist < (a->radius*a->radius)) {
				//std::cout << "asteroid hit." << std::endl;
				//this asteroid is hit.
				if (a->radius > 20.0) {
					//break it into pieces.
					Asteroid *ta = a;
					buildAsteroidFragment(ta, a);
					int r = rand()%10+5;
					for (int k=0; k<r; k++) {
						//get the next asteroid position in the array
						Asteroid *ta = new Asteroid;
						buildAsteroidFragment(ta, a);
						//add to front of asteroid linked list
						ta->next = g->ahead;
						if (g->ahead != NULL)
							g->ahead->prev = ta;
						g->ahead = ta;
						g->nasteroids++;
					}
				} else {
					a->color[0] = 1.0;
					a->color[1] = 0.1;
					a->color[2] = 0.1;
					//asteroid is too small to break up
					//delete the asteroid and bullet
					Asteroid *savea = a->next;
					deleteAsteroid(g, a);
					a = savea;
					g->nasteroids--;
				}
				//delete the bullet...
				Bullet *saveb = b->next;
				deleteBullet(g, b);
				b = saveb;
				g->nbullets--;
				if (a == NULL)
					break;
				continue;
			}
			b = b->next;
		}
		if (a == NULL)
			break;
		a = a->next;
	}
	//---------------------------------------------------
	//check keys pressed now
	if (keys[XK_Left]) {
		g->ship.angle += 4.0;
		if (g->ship.angle >= 360.0f)
			g->ship.angle -= 360.0f;
	}
	if (keys[XK_Right]) {
		g->ship.angle -= 4.0;
		if (g->ship.angle < 0.0f)
			g->ship.angle += 360.0f;
	}
	if (keys[XK_Up]) {
		//apply thrust
		//convert ship angle to radians
		Flt rad = ((g->ship.angle+90.0) / 360.0f) * PI * 2.0;
		//convert angle to a vector
		Flt xdir = cos(rad);
		Flt ydir = sin(rad);
		g->ship.vel[0] += xdir*0.02f;
		g->ship.vel[1] += ydir*0.02f;
		Flt speed = sqrt(g->ship.vel[0]*g->ship.vel[0]+
										g->ship.vel[1]*g->ship.vel[1]);
		if (speed > 10.0f) {
			speed = 10.0f;
			normalize(g->ship.vel);
			g->ship.vel[0] *= speed;
			g->ship.vel[1] *= speed;
		}
	}
	if (keys[XK_space]) {
		//a little time between each bullet
		struct timespec bt;
		clock_gettime(CLOCK_REALTIME, &bt);
		double ts = timeDiff(&g->bulletTimer, &bt);
		if (ts > 0.1) {
			timeCopy(&g->bulletTimer, &bt);
			//shoot a bullet...
			Bullet *b = new Bullet;
			timeCopy(&b->time, &bt);
			b->pos[0] = g->ship.pos[0];
			b->pos[1] = g->ship.pos[1];
			b->vel[0] = g->ship.vel[0];
			b->vel[1] = g->ship.vel[1];
			//convert ship angle to radians
			Flt rad = ((g->ship.angle+90.0) / 360.0f) * PI * 2.0;
			//convert angle to a vector
			Flt xdir = cos(rad);
			Flt ydir = sin(rad);
			b->pos[0] += xdir*20.0f;
			b->pos[1] += ydir*20.0f;
			b->vel[0] += xdir*6.0f + rnd()*0.1;
			b->vel[1] += ydir*6.0f + rnd()*0.1;
			b->color[0] = 1.0f;
			b->color[1] = 1.0f;
			b->color[2] = 1.0f;
			//add to front of bullet linked list
			b->next = g->bhead;
			if (g->bhead != NULL)
				g->bhead->prev = b;
			g->bhead = b;
			g->nbullets++;
		}
	}
}
int main(int argc, char *argv[])
{
	if(argc > 1) {
		if(argv[1] != NULL) {
			beginTesting();
		}
		return 0;
	}

	logOpen();
	initXWindows();
	init_opengl();
	Game game;
	init(&game);
	srand(time(NULL));
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);	

	hud = new Hud(xres ,yres);
	if (TEST_Hud){
		hud->testHUDAll();
		return 0;
	}
	//DEFUALT IS LEVEL 1 SELECTED:
	selected_screen = LEFT;    
	level =1;
	//--------------
	is_gameover = false;
	high_score = 0;
	gameStarted = false;
	lastPaddleHit = 'N';//'N' means no paddle hit

	bombBegin = time(NULL);
	bombRandom = random(7);

	beginSmallLeftPaddle = time(NULL);
	smallLeftPaddleTime = 7;
	beginSmallRightPaddle = time(NULL);
	smallRightPaddleTime = 7;
	hud->setAI(false);//DEFAULT: player2 is human	
	ball_saved_X_velocity = 8.0f * cos(30);
	ball_saved_Y_velocity = 8.0f * sin(90);    
	obstacle_saved_Y_velocity = -5.0;

	int min;
	if (xres<yres){
		min=xres;
	}
	else{
		min=yres;
	}
	bomb_radius = ((int)(3*min)/10);

	//MAIN MENU LOOP 
	while(intro != 0) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			intro = check_keys(&e, &game);
		}
		render(&game);
		glXSwapBuffers(dpy, win);
	}


	//BEGIN MAIN GAME LOOP
	int done=0;
	while (!done) {        
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			done = check_keys(&e, &game);
		}
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		while (physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}        
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	logClose();

	return 0;
}
Example #12
0
void PlayGame()
{
	bool menuToggle = true;
	Game game;
	game.setResolution(window_width, window_height);

	if(window_height > 1080)
	{
		//game.gravity = 9;
		MAX_VELOCITY = 12;
		INITIAL_VELOCITY = 7;
	}

	srand(time(NULL));

	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	clock_gettime(CLOCK_REALTIME, &start);
	while(game.run)
	{
		
		game = Game(); 			//reinitializes upon replay

		if(TOGGLE_SOUND)		//Sound switch so that the background music doesnt get recalled after the initial call
		{						//otherwise they loop over each other and it sounds bad, plus it created a memory leak
			Buffer = alutCreateBufferFromFile("./Sounds/music.wav");
			playBackgroundSound();
			TOGGLE_SOUND = false;
		}

		gutsToggle = true;
		bloodToggle = true;		//Reset switches to clear the prev game information. This includes the score and blood particles
		TOGGLE_PAUSE = true;	//basically reinitializing anything that didnt get reinitialized in the game = Game();
		numblood = 0;
		SCORE = 0;
		game.setMissiles = false;

		while(STATE == MAIN_MENU && game.run)
		{

			XEvent menu;
			while(XPending(dpy))
			{
				XNextEvent(dpy, &menu);
				check_keys(&menu, &game);											//Ahhh STATES, made this far easier to control.
				check_mouse(&menu, &game);											//Each while(STATE == X) loop renders a background and checks for input 
				game.setResolution(window_width, window_height);					//and the input functions all have checks to see what STATE is currently running
			}																		//and only allows proper input
			setMenuBackground();
			glXSwapBuffers(dpy, win);
		}

		while(STATE == HOW_TO && game.run && menuToggle)
		{

			XEvent howTo;
			while(XPending(dpy))
			{
				XNextEvent(dpy, &howTo);
				check_keys(&howTo, &game);
				check_mouse(&howTo, &game);
				game.setResolution(window_width, window_height);
			}
			setHowToBackground();
			glXSwapBuffers(dpy, win);
		}
		if(menuToggle)										//No one wants to see the how to menu over and over and over again.
			menuToggle = false;
		
		STATE = RUN_GAME; //gotta have this here, otherwise if the player clicks the green button after one game the STATE will be HOW_TO but it cant access it
		game.setResolution(window_width, window_height);
		game.setPos(window_width/2, window_height + game.player.height);	//this is when playforms are created and the players position is set to the top
		game.setGravity(GRAVITY);											//if this is called beforehand it wont take proper screen size into consideration
		makePlatform(5,&game);


		while(STATE == RUN_GAME && game.run)
		{

			// check input
			XEvent e;
			while(XPending(dpy))
			{
				if(TOGGLE_PAUSE)
				{
					TOGGLE_PAUSE = false;
					pausegame = false;
				}

				XNextEvent(dpy, &e);
				check_keys(&e, &game);
				check_resize(&e);
				game.setResolution(window_width, window_height);
			}


			if(game.guts && numblood <= 50)
			{
				STATE = DEATH;	//changes the game state to the death screen once the person has died and the blood particles are off the screen
			}

			clock_gettime(CLOCK_REALTIME, &timeCurrent);
			timeSpan = timeDiff(&timeStart, &timeCurrent);
			timeCopy(&timeStart, &timeCurrent);

			if(!pausegame && numblood < 1)
			{

				SCORE++;		//iterates the score every loop that the game is not paused and the player is not dead
			}

			physicsCountdown += timeSpan;

			// check for collisions, move player
			while(physicsCountdown >= physicsRate) {
				physics(&game);

				physicsCountdown -= physicsRate;
			}

			// used for sprite timing DON'T TOUCH
			if(frames > 2)
				frames = 0;
			frames++;

			// FPS COUNTER/RESET
			if(fps > 100)
			{
				clock_gettime(CLOCK_REALTIME, &start);
				fps = 0;
			}
			fps++;

			render(&game);
			glXSwapBuffers(dpy, win);

		}

		while(STATE == DEATH && game.run)
		{
			XEvent death;
			while(XPending(dpy))
			{
				XNextEvent(dpy, &death);
				check_keys(&death, &game);
				check_mouse(&death, &game);
				game.setResolution(window_width, window_height);
			}

			clock_gettime(CLOCK_REALTIME, &timeCurrent);
			timeSpan = timeDiff(&timeStart, &timeCurrent);
			timeCopy(&timeStart, &timeCurrent);
			physicsCountdown += timeSpan;
			while(physicsCountdown >= physicsRate)
			{
				physics(&game);
				physicsCountdown -= physicsRate;		//this will keep the game rendering so that the user can see the players full body explosion
			}
			render(&game);
			glXSwapBuffers(dpy, win);

		}

	}
	return;
}
Example #13
0
uint16_t checkForUpdatesToSend()
{
    // this needs to be the brain
    uint16_t cmd_code = 0;   
    static SMTPLUG_TM start_time_temp = 0, end_time_temp = 0;
    static SMTPLUG_Date_Time rtc_timer_temp = 0;

    signalsToSend = 0;
    // 0001 == need to update the plug status text field
    // 0010 == need to update the power save mode text field
    // 0100 == need to update the work timing text field
    

    //modeOrTargetTempChanged = 0;

    //AJ_AlwaysPrintf(("In checkForUpdatesToSend, currentMode=%d, targetTemp=%d, currentTemperature=%d, fanSpeed=%d, triggerAnUpdate=%d \n", currentMode, targetTemp, currentTemperature, fanSpeed, triggerAnUpdate));
    //AJ_AlwaysPrintf(("In checkForUpdatesToSend, curPlugMode=%d, curPowerSaveMode=%d, currentActPower=%d, currentTotalPower=%d, currentTotalPower=%d \n", currentPlugMode, currentPowerSaveMode, currentActPower, currentReactPower, currentTotalPower));
    //AJ_AlwaysPrintf(("totalActpowerSum=%d, gridfreq=%d, historyRunTime=%d \n", totalActpowerSum, gridfreq, historyRunTime));


    // check if the current plug mode has been changed & update accordingly
    if (currentPlugMode != previousPlugMode) {
      previousPlugMode = currentPlugMode;

      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_PWR_ONOFF), &currentPlugMode, 1);
      setPlugModeFieldUpdate();
    }

    if (currentPlugModeStatus != previousPlugModeStatus) {
      previousPlugModeStatus = currentPlugModeStatus;
      setPlugModeStatusFieldUpdate();

      if(currentPlugModeStatus == 0){             //Turn off plug
        //Plug Turn on
        plugstatusText[snprintf(plugstatusString, sizeof(plugstatusText), "Plug Power OFF")] = '\0';
        notificationText[snprintf(notificationString, sizeof(notificationText), "Plug Power OFF")] = '\0';
        sendANotification = 1;
      }
      else if(currentPlugModeStatus == 1){       //Turn on plug
        //Plug Turn on
        plugstatusText[snprintf(plugstatusString, sizeof(plugstatusText), "Plug Power ON ")] = '\0';
        notificationText[snprintf(notificationString, sizeof(notificationText), "Plug Power ON")] = '\0';
        sendANotification = 1;
      }
    }

	
    // check if the current plug power save mode has been changed & update accordingly
    if (currentPowerSaveMode != previousPowerSaveMode) {
      previousPowerSaveMode = currentPowerSaveMode;

      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_PWRSAVE_MODE), &currentPowerSaveMode, 1);
      setPowerSaveFieldUpdate();
      setPowerSaveStatusFieldUpdate();
      if(currentPowerSaveMode == 0){             //Turn off power save mode
       //Power save  Turn off
       set_wifi_sleep_mode(0);
        powersavestatusText[snprintf(powersavestatusString, sizeof(powersavestatusText), "PowerSave OFF ")] = '\0';
        notificationText[snprintf(notificationString, sizeof(notificationText), "PowerSave OFF ")] = '\0';
        sendANotification = 1;
      }
      else if(currentPowerSaveMode == 1){       //Turn on power save mode
        //Power save  Turn on
        set_wifi_sleep_mode(1);
        powersavestatusText[snprintf(powersavestatusString, sizeof(powersavestatusText), "PowerSave AUTO")] = '\0';
        notificationText[snprintf(notificationString, sizeof(notificationText), "PowerSave AUTO")] = '\0';
        sendANotification = 1;
      }
    }
    /* Update current Active Power display */
    if ((currentActPowerDec != previousActPowerDec)|| (currentActPowerInt != previousActPowerInt)) {
      previousActPowerDec = currentActPowerDec;
      previousActPowerInt = currentActPowerInt;
      setCurrentActivePowerFieldUpdate();
    }
    
    /* Update current Reactive Power display */
    if ((currentReactPowerDec != previousReactPowerDec)||(currentReactPowerInt != previousReactPowerInt)) {
      previousReactPowerDec = currentReactPowerDec;
      previousReactPowerInt = currentReactPowerInt;
      setCurrentReactivePowerFieldUpdate();
    }

    /* Update current Total Power display */
    if ((currentTotalPowerDec != previousTotalPowerDec)||(currentTotalPowerInt != previousTotalPowerInt)) {
      previousTotalPowerDec = currentTotalPowerDec;
      previousTotalPowerInt = currentTotalPowerInt;
      setCurrentTotalPowerFieldUpdate();
    }

    /* Update Total Active Power Sum display */
    if ((totalActpowerSumDec != previousActpowerSumDec)||(totalActpowerSumInt != previousActpowerSumInt)){
      previousActpowerSumDec = totalActpowerSumDec;
      previousActpowerSumInt = totalActpowerSumInt;
      setTotalActivePowerSumFieldUpdate();
    }

    /* Grid Frequence */
    if ((gridfreq != previousGridFreq)){
      previousGridFreq = gridfreq;
      setCurrentGridPreqFieldUpdate();
    }
    
     /* Work history run time*/
     if ((historyRunTime != prevHistoryRunTime)){
       prevHistoryRunTime = historyRunTime;
       setHistoryRunTimeFieldUpdate();
    }
    
    /* Set work timer ON/OFF */
    if(workTimerONOFF != previous_workTimerONOFF){	
      previous_workTimerONOFF = workTimerONOFF;

      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_TIMER_ONOFF), &workTimerONOFF, 1);
      setWorkTimerONOFFFieldUpdate();
      if(workTimerONOFF == 0){             //Turn off plug
        //Turn off Work timer 
      }
      else if(workTimerONOFF == 1){
        //Turn on Work timer  
      }
    }

    /* Set work start time */
    if(isTimeDiffernt(&fliptime, &previousFliptime)){	
      timeCopy(&previousFliptime, &fliptime);

      start_time_temp.hour = fliptime.hour;
      start_time_temp.min = fliptime.minute;
      start_time_temp.sec = fliptime.second;
      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_TIMER_BEGIN), &start_time_temp, sizeof(SMTPLUG_TM));
      setStartTimingFieldUpdate();
    }
    /* Set work end time */
    if(isTimeDiffernt(&end_fliptime, &previous_end_fliptime)){	
      timeCopy(&previous_end_fliptime, &end_fliptime);

      end_time_temp.hour = end_fliptime.hour;
      end_time_temp.min = end_fliptime.minute;
      end_time_temp.sec = end_fliptime.second;  
      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_TIMER_END), &end_time_temp, sizeof(SMTPLUG_TM));
      setEndTimingFieldUpdate();
    }
    /* Set RTC adjuste date */
    if(isDateDiffernt(&rtc_date, &previous_rtc_date)){	
      dateCopy(&previous_rtc_date, &rtc_date);
      setRTCDateFieldUpdate();
    }
    /* Set RTC adjuste time */
    if(isTimeDiffernt(&rtc_time, &previous_rtc_time)){	
      timeCopy(&previous_rtc_time, &rtc_time);
      rtc_timer_temp.year = rtc_date.fullYear;
      rtc_timer_temp.mon = rtc_date.month;
      rtc_timer_temp.mday = rtc_date.mDay;
      rtc_timer_temp.hour = rtc_time.hour;
      rtc_timer_temp.min = rtc_time.minute;
      rtc_timer_temp.sec = rtc_time.second;

      command_send(CMD_SET, cls_shiftor_opc(SMTPLG_CMD_CLS_APP, SMTPLG_CMD_OP_SET_CUR_TIME), &rtc_timer_temp, sizeof(SMTPLUG_Date_Time));
      setRTCTimeFieldUpdate();
    }
	
    return signalsToSend;
}