Example #1
0
 public void setstatus(testStatus s)
 {
     changedState = s;
 }
Example #2
0
        private void Update()
        {
            if (curState != changedState)
            {
                curState = changedState;
                ChangeMode(curState, param1, param2);
            }
            if (curState == testStatus.Loading)
            {
                if (datasize != 0)
                {
                    loading.text = "loading : " + progress + "%";
                }
            }
            else if (curState == testStatus.Result)
            {
                RectTransform rt = goN.GetComponent <RectTransform>();
                if (rt.anchoredPosition.x < N)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x + 1, rt.anchoredPosition.y);
                }
                else if (rt.anchoredPosition.x > N)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x - 1, rt.anchoredPosition.y);
                }

                rt = goE.GetComponent <RectTransform>();
                if (rt.anchoredPosition.x < E)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x + 1, rt.anchoredPosition.y);
                }
                else if (rt.anchoredPosition.x > E)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x - 1, rt.anchoredPosition.y);
                }

                rt = goO.GetComponent <RectTransform>();
                if (rt.anchoredPosition.x < O)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x + 1, rt.anchoredPosition.y);
                }
                else if (rt.anchoredPosition.x > O)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x - 1, rt.anchoredPosition.y);
                }

                rt = goC.GetComponent <RectTransform>();
                if (rt.anchoredPosition.x < C)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x + 1, rt.anchoredPosition.y);
                }
                else if (rt.anchoredPosition.x > C)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x - 1, rt.anchoredPosition.y);
                }

                rt = goA.GetComponent <RectTransform>();
                if (rt.anchoredPosition.x < A)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x + 1, rt.anchoredPosition.y);
                }
                else if (rt.anchoredPosition.x > A)
                {
                    rt.anchoredPosition = new Vector2(rt.anchoredPosition.x - 1, rt.anchoredPosition.y);
                }
                rN.text = "Neuroticism : " + (N + 50).ToString();
                rE.text = "Extraversion : " + (E + 50).ToString();
                rO.text = "Openness : " + (O + 50).ToString();
                rC.text = "Conscientiousness : " + (C + 50).ToString();
                rA.text = "Agreeableness : " + (A + 50).ToString();
            }
        }
Example #3
0
        private void ChangeMode(testStatus status, int param1, int param2)
        {
            DeactiveAll();

            switch (status)
            {
            //프로그램 시작시
            case testStatus.Intro:
                test.instance.startT2();
                test.instance.Init();
                tex = new Texture2D(2, 2);
                Debug.Log("status : intro");
                break;

            //TCP 연결시
            case testStatus.Connect:
                test.instance.startT1();
                Debug.Log("status : connect");
                break;

            //video(mp4) 데이터 수신시
            case testStatus.Video:
                /*
                 * param1 : 1 = stereo 2 = 180 angle 3 = 360 angle
                 * param2 : 1 = none 2 = topbottom 3 = leftright
                 */
                byte[] temp = test.instance.getData();
                queue.Enqueue(temp);
                queue1.Enqueue(param1);
                queue2.Enqueue(param2);
                if (tf)
                {
                    videostart();
                    tf = false;
                }
                break;

            //image(jpg) 데이터 수신시
            case testStatus.Image:
                tex.LoadImage(test.instance.getData());
                float width  = tex.width;
                float height = tex.height;
                test.instance.image.sprite = Sprite.Create(tex, new Rect(0, 0, width, height), new Vector2());
                test.instance.image.gameObject.SetActive(true);
                test.instance.setData(null);
                Debug.Log("status : image");
                if (tf)
                {
                    tf = false;
                }
                break;

            //예정 : TCP 연결전 대기화면 ,PC에 녹화된 뇌파 데이터 분석 요구
            case testStatus.Loading:
                if (tf)
                {
                    if (datasize == 0)
                    {
                        loading.text = "Analysis Loading.......";
                    }
                    test.instance.loading.SetActive(true);
                    Debug.Log("status : loading");
                }
                break;

            //예정 : PC에서 분석된 결과 표시
            case testStatus.Result:
                N       = Random.Range(-50, 51);
                rN.text = "Neuroticism : " + (N + 50).ToString();
                E       = Random.Range(-50, 51);
                rE.text = "Extraversion : " + (E + 50).ToString();
                O       = Random.Range(-50, 51);
                rO.text = "Openness : " + (O + 50).ToString();
                C       = Random.Range(-50, 51);
                rC.text = "Conscientiousness : " + (C + 50).ToString();
                A       = Random.Range(-50, 51);
                rA.text = "Agreeableness : " + (A + 50).ToString();

                /*
                 * 계획 : testclass에서 받은 결과 저장
                 */
                test.instance.result.SetActive(true);
                Debug.Log("status : result");
                break;

            //프로그램 종료
            case testStatus.End:
                test.instance.joinT1();
                test.instance.joinT2();
                Debug.Log("status : end");
                break;

            default:
                break;
            }
        }