TEST(QST, TestPartTrace) {
    QuantumState state1(Vector2cd(1,1), HilbertSpace(2)), state2(Vector2cd(1,-1), HilbertSpace(2));
    QuantumState tens = QuantumState::tensor(state1, state2);
    
    EXPECT_EQ(state1, tens.partialTrace(1));
    EXPECT_EQ(state2, tens.partialTrace(0));
    EXPECT_ANY_THROW(tens.partialTrace(-1));
    EXPECT_ANY_THROW(tens.partialTrace(2));
}
Example #2
0
char state0(){

	if(isalpha(currChar)){
		return state1();
	}else{
		return state2();
	}

}
// One-size-fits-all update func
void borderFunc()
{
	if (state == 1)
		state1();
	if (state == 3)
		state2();
	if (state == 4)
		state3();
	if (state == 2)
		state4();
	fourPorts();
}
Example #4
0
void main (void)
{
  int cs = 1;
  while (1)
    {
      /* Display current state on LED */

      if (cs == 10)
	leddisplay ('0');
      else
	leddisplay ('0' + cs);
      switch (cs)
	{
	case 1:
	  cs = state1 ();
	  break;
	case 2:
	  cs = state2 ();
	  break;
	case 3:
	  cs = state3 ();
	  break;
	case 4:
	  cs = state4 ();
	  break;
	case 5:
	  cs = state5 ();
	  break;
#if 0
	case 6:
	  cs = state6 ();
	  break;
#endif
	case 7:
	  cs = state7 ();
	  break;
	case 8:
	  cs = state8 ();
	  break;
#if 0
	case 9:
	  cs = state9 ();
	  break;
#endif
	case 10:
	  cs = state10 ();
	  break;
	default:
	  cs = 1;
	  break;
	}
    }
}
// Processes an event which drives a change in state.
void processEvent (char event) {
	int ProcessedCorrectly = 0;
	currentState = peek ();

	printf ("Processing event: %c for state: %c \n", event, currentState);

	switch(currentState) {
		case STATE0:
			ProcessedCorrectly = state0 (event);
			break;
		case STATE1:
			ProcessedCorrectly = state1 (event);
			break;
		case STATE2:
			ProcessedCorrectly = state2 (event);
			break;
		case STATE3:
			ProcessedCorrectly = state3 (event);
			break;
		case STATE4:
			ProcessedCorrectly = state4 (event);
			break;
		case STATE5:
			ProcessedCorrectly = state5 (event);
			break;
		case STATE6:
			ProcessedCorrectly = state6 (event);
			break;
		case STATE7:
			ProcessedCorrectly = state7 (event);
			break;
		case STATE8:
			ProcessedCorrectly = state8 (event);
			break;
		case STATE9:
			ProcessedCorrectly = state9 (event);
			break;
		case STATEA:
			ProcessedCorrectly = state10 (event);
			break;
		case STATEB:
			ProcessedCorrectly = state11 (event);
			break;
		default:
			printf ("Unknown state %d for event  %c \n", currentState, event);
			ProcessedCorrectly = 1;
		}
	if(ProcessedCorrectly == 1) {
		printf ("The Grammar Failed The Syntax Machine\n");
		exit (0);
		}
	}
Example #6
0
char state1(){
	currChar = nextChar();
	if(currChar == 0){
		return 'w';
	}

	if(isalpha(currChar)){
		return state1();
	}else{
		return 'm';
	}

}
Example #7
0
 Q_SLOT void test2() {
    // Uses SignalWaiter
    Foo foo;
    SignalWaiter state1(&foo.m_state1, SIGNAL(entered()));
    SignalWaiter state2(&foo.m_state2, SIGNAL(entered()));
    foo.start();
    state1.wait();
    QCOMPARE(state1.count(), 1);
    emit foo.sigGoToStateTwo();
    state2.wait();
    QCOMPARE(state2.count(), 1);
    emit foo.sigGoToStateOne();
    state1.wait();
    QCOMPARE(state1.count(), 2);
 }
Example #8
0
 Q_SLOT void test1() {
    // Uses QSignalSpy
    Foo foo;
    SignalSpy state1(&foo.m_state1, SIGNAL(entered()));
    SignalSpy state2(&foo.m_state2, SIGNAL(entered()));
    call(&foo, "start");
    state1.wait();
    QCOMPARE(state1.count(), 1);
    call(&foo, "sigGoToStateTwo");
    state2.wait();
    QCOMPARE(state2.count(), 1);
    call(&foo, "sigGoToStateOne");
    state1.wait();
    QCOMPARE(state1.count(), 2);
 }
Example #9
0
TEST_F(TestActiveStateWithArgs,DirectTransition1)
{
    ::testing::NiceMock<TestStateMachineWithEventArgsMock> stateMachine;
    ::testing::NiceMock
        < TestActiveStateWithArgsMock<TestStateMachineWithEventArgsMock>
        > state1(false,sttcl::TimeDuration<>(0,0,0,100),"state1");
    ::testing::NiceMock
        < TestSimpleStateWithArgsMock<TestStateMachineWithEventArgsMock>
        > state2("state2");

    stateMachine.autoFinalize(false);
    stateMachine.initialState(&state1);
    state1.setDirectTransitState(&state2);

    // Setup mock call expectations
    //----------------------------------------------------------------------------
    EXPECT_CALL(state1,checkDirectTransitionImpl(_,_,_))
        .Times(AtLeast(1));
    EXPECT_CALL(state1,exitingDoActionImpl())
        .Times(1);

    EXPECT_CALL(state2,entryImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(state2,startDoImpl(&stateMachine))
        .Times(1);
// Direct transition prevents initializing sub state machines
//    EXPECT_CALL(state2,initSubStateMachinesImpl(_))
//        .Times(1);
    EXPECT_CALL(state2,finalizeSubStateMachinesImpl(true))
        .Times(1);
    EXPECT_CALL(state2,endDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(state2,exitImpl(&stateMachine))
        .Times(1);

    // Run the state machine
    //----------------------------------------------------------------------------
//    stateMachine.enableLogging(true);
//    state1.enableLogging(true);
//    state2.enableLogging(true);

    stateMachine.initialize(true);
    EXPECT_TRUE(state1.waitForDoActionExited(sttcl::TimeDuration<>(0,0,0,100),5));
    stateMachine.finalize(true);
}
Example #10
0
TEST( RenderingView, manySingleStatesBatching )
{
   // setup reflection types
   ReflectionTypesRegistry& typesRegistry = ReflectionTypesRegistry::getInstance();
   typesRegistry.addSerializableType< Geometry >( "Geometry", NULL );
   typesRegistry.addSerializableType< Light >( "Light", NULL );
   typesRegistry.addSerializableType< RenderStateMock >( "RenderStateMock", NULL );

   RenderStateMock state1( "1" );
   RenderStateMock state2( "2" );
   RenderStateMock state3( "3" );
   RenderStateMock state4( "4" );

   GeometryMock* g1 = new GeometryMock( "1" );
   GeometryMock* g2 = new GeometryMock( "2" );
   GeometryMock* g3 = new GeometryMock( "3" );
   GeometryMock* g4 = new GeometryMock( "4" );

   g1->addState( state1 );
   g2->addState( state2 );
   g3->addState( state3 );
   g4->addState( state3 );

   Model model;
   model.add( g1 );
   model.add( g2 );
   model.add( g3 );
   model.add( g4 );

   // setup the renderer
   RendererMock renderer;
   renderer.setMechanism( new RenderingMechanismMock( model ) );

   // move the camera so that the entire scene is visible
   renderer.getActiveCamera().accessLocalMtx().setTranslation( Vector( 0, 0, -10 ) );

   // render the scene
   renderer.render();
   CPPUNIT_ASSERT_EQUAL( std::string( "set RS 1;RenderGeometry_1;reset RS 1;set RS 2;RenderGeometry_2;reset RS 2;set RS 3;RenderGeometry_4;RenderGeometry_3;reset RS 3;" ), renderer.m_seqLog );

   // cleanup
   typesRegistry.clear();
}
void CSsmRepeatedPublishStateTest::DoRepeatedPublishStateL()
	{
	INFO_PRINTF1(_L("Doing a single sync RequestStateTransition then cancelling it with another..."));

	const TInt connect = iClient.Connect();
	TEST(KErrNone == connect);	
	iClient.HeapMark();
	
	INFO_PRINTF1(_L("Creating P+S value for custom command to wait on"));
	TInt err = RProperty::Define(KMySID, EPnSFnFCustomCommandValue, RProperty::EInt, EFalse);
	if(err != KErrNone && err != KErrAlreadyExists)
		{	
		INFO_PRINTF3(_L("Error when defining property 0x%x: %d"), EPnSFnFCustomCommandValue, err);
		User::Leave(err);
		}
	err = RProperty::Set(KMySID, EPnSFnFCustomCommandValue, 0);
	TEST(err == KErrNone);
	User::LeaveIfError(err);	
	
	// Request state change
	INFO_PRINTF1(_L("Request state transition to state EStateWithWaitingFnFPnSCustomCommand...")); 
	TSsmStateTransition state1(KSsmTestGenericState, EStateWithWaitingFnFPnSCustomCommand, 0);
	RequestAndWaitForStateTransitionL(state1);
	
	INFO_PRINTF1(_L("State transitions completed successfully"));
	INFO_PRINTF1(_L("Setting publish and subscribe value to complete FnF custom command"));
	err = RProperty::Set(KMySID, EPnSFnFCustomCommandValue, 1);
	TEST(err == KErrNone);
	User::LeaveIfError(err);		
	
	User::After(500000);	//Wait for 0.5sec to allow transitions to fully complete
	
	iClient.HeapMarkEnd(EDoCleanup);		//Pass EDoCleanup for cleaning up Transition Engine after the test case 	
	// clean-up
	iClient.Close();
	INFO_PRINTF1(_L("case completed\n"));
	}
Example #12
0
void vt_out(struct term_t *pwin, unsigned int ch)
{
  int f;
  unsigned char c;
  int go_on = 0;
  wchar_t wc;
  term_t *win;

  win = (term_t *)pwin;
  if (!ch)
    return;


  c = (unsigned char)ch;

  if (win->state.vt_docap == 2) /* Literal. */
    fputc(c, win->state.capfp);

  /* Process <31 chars first, even in an escape sequence. */
  switch (c) {
    case '\r': /* Carriage return */
      term_wputc(win, c);
      if (win->state.vt_addlf) {
        term_wputc(win, '\n');
        if (win->state.vt_docap == 1)
          fputc('\n', win->state.capfp);
      }
      break;
    case '\t': /* Non - destructive TAB */
//      printf("tab pants\n");
      /* Find next tab stop. */
      for (f = win->cursor_x + 1; f < 160; f++)
        if (win->state.vt_tabs[f / 32] & (1 << f % 32))
          break;
      if (f >= win->W)
        f = win->W - 1;
      term_wlocate(win, f, win->cursor_y);
      if (win->state.vt_docap == 1)
        fputc(c, win->state.capfp);
      break;
    case 013: /* Old Minix: CTRL-K = up */
      term_wlocate(win, win->cursor_x, win->cursor_y - 1);
      break;
    case '\f': /* Form feed: clear screen. */
      term_winclr(win);
      term_wlocate(win, 0, 0);
      break;
    case 14:
      break;
    case 15:
      break;
    case 24:
    case 26:  /* Cancel escape sequence. */
      esc_s = 0;
      break;
    case ESC: /* Begin escape sequence */
      esc_s = 1;
      break;
    case 128+ESC: /* Begin ESC [ sequence. */
      esc_s = 2;
      break;
    case '\n':
    case '\b':
    case 7: /* Bell */
      term_wputc(win, c);
      if (win->state.vt_docap == 1)
        fputc(c, win->state.capfp);
      break;
    default:
      go_on = 1;
      break;
  }
  if (!go_on)
    return;
 

  /* Now see which state we are in. */
  switch (esc_s) {
    case 0: /* Normal character */
      /* XXX:mappers */
      c&=0xff;

      if (!win->state.enable_iconv) {
        one_mbtowc ((char *)&wc, (char *)&c, 1); 
        if (win->state.vt_insert)
          term_winschar(win, wc, 1);
        else
          term_wputc(win, wc);
      } else 
        term_wputc(win, c);
     
      break;
    case 1: /* ESC seen */
      state1(win, c);
      break;
    case 2: /* ESC [ ... seen */
      state2(win, c);
      break;
    case 3:
      state3(win, c);
      break;
    case 4:
      state4(win, c);
      break;
    case 5:
      state5(win, c);
      break;
    case 6:
      state6(win, c);
      break;
    case 7:
      state7(win,c);
      break;
  }

}
Example #13
0
void vt_out(int ch)
{
  static unsigned char last_ch;
  int f;
  unsigned char c;
  int go_on = 0;
  wchar_t wc;

  if (!ch)
    return;

  if (last_ch == '\n'
      && vt_line_timestamp != TIMESTAMP_LINE_OFF)
    {
      struct timeval tmstmp_now;
      static time_t tmstmp_last;
      char s[36];
      struct tm tmstmp_tm;

      gettimeofday(&tmstmp_now, NULL);
      if ((   vt_line_timestamp == TIMESTAMP_LINE_PER_SECOND
           && tmstmp_now.tv_sec != tmstmp_last)
          || vt_line_timestamp == TIMESTAMP_LINE_SIMPLE
          || vt_line_timestamp == TIMESTAMP_LINE_EXTENDED)
        {
          if (   localtime_r(&tmstmp_now.tv_sec, &tmstmp_tm)
              && strftime(s, sizeof(s), "[%F %T", &tmstmp_tm))
            {
              output_s(s);
              switch (vt_line_timestamp)
                {
                case TIMESTAMP_LINE_SIMPLE:
                  output_s("] ");
                  break;
                case TIMESTAMP_LINE_EXTENDED:
                  snprintf(s, sizeof(s), ".%03ld] ", tmstmp_now.tv_usec / 1000);
                  output_s(s);
                  break;
                case TIMESTAMP_LINE_PER_SECOND:
                  output_s("\r\n");
                  break;
                };
            }
          tmstmp_last = tmstmp_now.tv_sec;
        }
    }

  c = (unsigned char)ch;
  last_ch = c;

  if (vt_docap == 2) /* Literal. */
    fputc(c, capfp);

  /* Process <31 chars first, even in an escape sequence. */
  switch (c) {
    case 5: /* AnswerBack for vt100's */
      if (vt_type != VT100) {
        go_on = 1;
        break;
      }
      v_termout(P_ANSWERBACK, 0);
      break;
    case '\r': /* Carriage return */
      mc_wputc(vt_win, c);
      if (vt_addlf)
        output_c('\n');
      break;
    case '\t': /* Non - destructive TAB */
      /* Find next tab stop. */
      for (f = vt_win->curx + 1; f < 160; f++)
        if (vt_tabs[f / 32] & (1 << f % 32))
          break;
      if (f >= vt_win->xs)
        f = vt_win->xs - 1;
      mc_wlocate(vt_win, f, vt_win->cury);
      if (vt_docap == 1)
        fputc(c, capfp);
      break;
    case 013: /* Old Minix: CTRL-K = up */
      mc_wlocate(vt_win, vt_win->curx, vt_win->cury - 1);
      break;
    case '\f': /* Form feed: clear screen. */
      mc_winclr(vt_win);
      mc_wlocate(vt_win, 0, 0);
      break;
#if !TRANSLATE
    case 14:
    case 15:  /* Change character set. Not supported. */
      break;
#else
    case 14:
      vt_charset = 1;
      break;
    case 15:
      vt_charset = 0;
      break;
#endif
    case 24:
    case 26:  /* Cancel escape sequence. */
      esc_s = 0;
      break;
    case ESC: /* Begin escape sequence */
      esc_s = 1;
      break;
    case 128+ESC: /* Begin ESC [ sequence. */
      esc_s = 2;
      break;
    case '\n':
      if(vt_addcr)
        mc_wputc(vt_win, '\r');
      output_c(c);
	  break;
    case '\b':
    case 7: /* Bell */
      output_c(c);
      break;
    default:
      go_on = 1;
      break;
  }
  if (!go_on)
    return;

  /* Now see which state we are in. */
  switch (esc_s) {
    case 0: /* Normal character */
      if (vt_docap == 1)
        fputc(P_CONVCAP[0] == 'Y' ? vt_inmap[c] : c, capfp);
      if (!using_iconv()) {
        c = vt_inmap[c];    /* conversion 04.09.97 / jl */
#if TRANSLATE
        if (vt_type == VT100 && vt_trans[vt_charset] && vt_asis == 0)
          c = vt_trans[vt_charset][c];
#endif
      }
      /* FIXME: This is wrong, but making it right would require
       * removing all the 8-bit mapping features. Assuming the locale
       * is 8-bit, the character should not be changed by mapping to
       * wchar and back; if the locale is multibyte, there is no hope
       * of getting it right anyway. */
      if (!using_iconv()) {
        one_mbtowc (&wc, (char *)&c, 1); /* returns 1 */
        if (vt_insert)
          mc_winschar2(vt_win, wc, 1);
        else
          mc_wputc(vt_win, wc);
      } else {
        mc_wputc(vt_win, c);
      }
      break;
    case 1: /* ESC seen */
      state1(c);
      break;
    case 2: /* ESC [ ... seen */
      state2(c);
      break;
    case 3:
      state3(c);
      break;
    case 4:
      state4(c);
      break;
    case 5:
      state5(c);
      break;
    case 6:
      state6(c);
      break;
    case 7:
      state7(c);
      break;
  }

  /* Flush output to capture file so that all output is visible there
   * immediately. Causes a write syscall for every call though. */
  if (capfp)
    fflush(capfp);
}
Example #14
0
/* function DisplayCallbackFunction(void)
* Description:
*  - this is the openGL display routine
*  - this draws the sprites appropriately
*/
void DisplayCallbackFunction(void)
{

	/* clear the screen */
	glClearColor(0.2f, 0.2f, 0.2f, 0.8f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// borders--------------------------------------
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glViewport(0, 0, windowWidth, windowHeight);



	if (state == 0) // Default View
	{
		fourPorts();

		//first viewpoint

		glMatrixMode(GL_PROJECTION);
		glViewport(0, 0, windowWidth / 2, windowHeight / 2);
		Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity(); // clear our the transform matrix
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam1.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Second Viewport -----------------------------------------------------

		glMatrixMode(GL_PROJECTION);
		glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
		cam2.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Third viewport-----------------------------------------------------------------------------

		glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam3.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();


		//Fourth viewport--------------------------------------------------------------------------------------------

		glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
		cam4.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		drawSceneObjects();

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glViewport(0, 0, windowWidth, windowHeight);
	}

	if (state == 1)
	{
		state1();
		fourPorts();

		//Second Viewport -----------------------------------------------------

		glMatrixMode(GL_PROJECTION);
		glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
		cam2.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Third viewport-----------------------------------------------------------------------------

		glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam3.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();


		//Fourth viewport--------------------------------------------------------------------------------------------

		glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
		cam4.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		drawSceneObjects();

		// Update

		//first viewport

		glMatrixMode(GL_PROJECTION);
		glViewport(0, 0, windowWidth / 2, windowHeight / 2);
		Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity(); // clear our the transform matrix
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam1.applyCameraTransformations();
		cam = cam1;
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		//Draw Shapes

		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}

	if (state == 2)
	{
		state2();
		fourPorts();

		//first viewpoint

		glMatrixMode(GL_PROJECTION);
		glViewport(0, 0, windowWidth / 2, windowHeight / 2);
		Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity(); // clear our the transform matrix
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam1.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Third viewport-----------------------------------------------------------------------------

		glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam3.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();


		//Fourth viewport--------------------------------------------------------------------------------------------

		glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
		cam4.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		drawSceneObjects();

		// Update Cam--------------

		updateEm();

		//Second Viewport -----------------------------------------------------

		glMatrixMode(GL_PROJECTION);
		glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
		cam2.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	}

	if (state == 3)
	{
		state3();
		fourPorts();

		//first viewpoint

		glMatrixMode(GL_PROJECTION);
		glViewport(0, 0, windowWidth / 2, windowHeight / 2);
		Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity(); // clear our the transform matrix
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam1.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Second Viewport -----------------------------------------------------

		glMatrixMode(GL_PROJECTION);
		glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
		cam2.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Fourth viewport--------------------------------------------------------------------------------------------

		glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
		cam4.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		drawSceneObjects();

		// Update Cam

		updateEm();

		//Third viewport-----------------------------------------------------------------------------

		glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam3.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}

	if (state == 4)
	{
		state4();
		fourPorts();

		//first viewpoint

		glMatrixMode(GL_PROJECTION);
		glViewport(0, 0, windowWidth / 2, windowHeight / 2);
		Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity(); // clear our the transform matrix
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam1.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Second Viewport -----------------------------------------------------

		glMatrixMode(GL_PROJECTION);
		glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
		cam2.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		//Third viewport-----------------------------------------------------------------------------

		glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
		cam3.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		drawSceneObjects();

		// Update Cam

		updateEm();

		//Fourth viewport--------------------------------------------------------------------------------------------

		glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
		glMatrixMode(GL_PROJECTION);
		Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
		glLoadIdentity();
		gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
		cam4.applyCameraTransformations();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		drawSceneObjects();
	}
	static unsigned int oldTimeSinceStart = 0;
	unsigned int timeSinceStart = glutGet(GLUT_ELAPSED_TIME);
	unsigned int deltaT = timeSinceStart - oldTimeSinceStart;
	oldTimeSinceStart = timeSinceStart;

	cam.Update((float)deltaT / 1000.0);
	cam.applyCameraTransformations();
	//end of borders---------------------------------

	//first viewpoint

	//glMatrixMode(GL_PROJECTION);
	//glViewport(0, 0, windowWidth / 2, windowHeight / 2);
	//Camera cam1(0.0f, 0.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
	//glLoadIdentity(); // clear our the transform matrix
	//glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
	//cam1.applyCameraTransformations();
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	//drawSceneObjects();
	//
	////Second Viewport -----------------------------------------------------
	//
	//glMatrixMode(GL_PROJECTION);
	//glViewport(windowWidth / 2, windowHeight / 2, windowWidth / 2, windowHeight / 2);
	//Camera cam2(10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
	//glLoadIdentity();
	//glOrtho(-30.0f, 30.0f, -30.0f, 30.0f, 1.0f, 100.0f);
	//cam2.applyCameraTransformations();
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	//drawSceneObjects();
	//
	////Third viewport-----------------------------------------------------------------------------
	//
	//glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight / 2);
	//glMatrixMode(GL_PROJECTION);
	//Camera cam3(0.0f, 10.0f, 0.0000001f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
	//glLoadIdentity();
	//glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100.0f);
	//cam3.applyCameraTransformations();
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	//drawSceneObjects();
	//
	//
	////Fourth viewport--------------------------------------------------------------------------------------------
	//
	//glViewport(0, windowHeight / 2, windowWidth / 2, windowHeight / 2);
	//glMatrixMode(GL_PROJECTION);
	//Camera cam4(5.0f, 5.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
	//glLoadIdentity();
	//gluPerspective(90.0f, 1.0f, 1.0f, 100.0f);
	//cam4.applyCameraTransformations();
	//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	//drawSceneObjects();

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


	/* Swap Buffers to Make it show up on screen */
	glutSwapBuffers();
}
TEST(StateTest, State_TwoDifferentStates_NotEqual){
    State state1(0);
    State state2(1);

    EXPECT_NE(state1, state2);
}
void CSsmSwpDependenciesTest::DoStateRequestWithDependentSwp()
	{
	INFO_PRINTF1(_L("Doing a single async RequestStateTransition that will cause dependent swp to be changed too."));

	RSsmStateManagerTestClient client;
	TInt connect = client.Connect();
	TEST(KErrNone == connect);

	// Create dependent swps
	INFO_PRINTF1(_L("Creating dependent swp..."));
	TSsmSwp swp3(KTestDependentSwp3, 30);
	RProperty property3;
	TEST(KErrNone == property3.Define(KPropertyCategory, swp3.Key(), RProperty::EInt));
	TEST(KErrNone == property3.Set(KPropertyCategory, swp3.Key(), swp3.Value()));
	
	TSsmSwp swp4(KTestDependentSwp4, 40);
	RProperty property4;
	TEST(KErrNone == property4.Define(KPropertyCategory, swp4.Key(), RProperty::EInt));
	TEST(KErrNone == property4.Set(KPropertyCategory, swp4.Key(), swp4.Value()));
	
	//Ensure the environment is clean
	TInt value = 0;
	TEST(KErrNone == property3.Get(KPropertyCategory, swp3.Key(), value));
	TESTE(30 == value, value);
	
	TEST(KErrNone == property4.Get(KPropertyCategory, swp4.Key(), value));
	TESTE(40 == value, value);
	
	// Register mapping between keys and swp policy DLL (done once per ssmserver)
	INFO_PRINTF1(_L("Registering swps..."));
	TEST(KErrNone == client.RegisterSwpMapping(KTestDependentSwp3, KTestSwpPolicyCommonFile));
	TEST(KErrNone == client.RegisterSwpMapping(KTestDependentSwp4, KTestSwpPolicyCommonFile));
	
	//Register the swp's even with the main servers as the dependent swp change commands which are
	//requested from inside the state/swp policy will go to the main server as they use RSsmStateManager 
	//instead of RSsmStateManagerTestClient which is the test client.
	RSsmStateManager client2;
	connect = client2.Connect();
	TEST(KErrNone == connect);

	TEST(KErrNone == client2.RegisterSwpMapping(KTestDependentSwp3, KTestSwpPolicyCommonFile));
	TEST(KErrNone == client2.RegisterSwpMapping(KTestDependentSwp4, KTestSwpPolicyCommonFile));
	client2.Close();

	// Request state transitions in the session
	INFO_PRINTF1(_L("Request state transition")); 
	TSsmStateTransition state1(ESsmTestDependencyState,123,456);
	TRequestStatus status1;
	client.RequestStateTransition(state1, status1);				// (simple) policy returns EDefinitelyAllowed
	TEST(status1 == KRequestPending);
	
	User::WaitForRequest(status1);
	INFO_PRINTF2(_L("  --completion codes:  req1 (%d)"), status1.Int());
	TEST(status1.Int() == KErrNone);

	RSsmSystemWideProperty swpPropNotif;
	//Connect to the last swp.
	TInt err = swpPropNotif.Connect(swp4.Key());
	INFO_PRINTF2(_L("Connect to RSsmSystemWideProperty completed with %d"), err);
	TEST(err == KErrNone);
	
	value = 0;
	//Ensure that the swp is not change already.
	TEST(KErrNone == property4.Get(KPropertyCategory, swp4.Key(), value));
	if(40 == value)
		{
		TRequestStatus status_Notif;
		swpPropNotif.Subscribe(status_Notif);
		
		//Wait till the swp value has been changed.
		User::WaitForRequest(status_Notif);
		TEST(KErrNone == status_Notif.Int());
		}
	
	swpPropNotif.Close();

	//Ensure all properties were properly updated
	value = 0;
	TEST(KErrNone == property3.Get(KPropertyCategory, swp3.Key(), value));
	TESTE(123+456 == value, value);		// As per the state dependency policy (reason + sub state)

	TEST(KErrNone == property4.Get(KPropertyCategory, swp4.Key(), value));
	TESTE(456-123 == value, value);		// As per the state dependency policy (reason - sub state)

	// clean-up
	TEST(KErrNone == property3.Delete(KPropertyCategory, swp3.Key()));
	TEST(KErrNone == property4.Delete(KPropertyCategory, swp4.Key()));
	property3.Close();
	property4.Close();
	client.Close();
	INFO_PRINTF1(_L("case completed\n"));
	}