Пример #1
0
    private void Update()
    {
        prevState = curState;

        if (curState != Tutorial2Status.Image)
        {
            return;
        }

        timer += Time.deltaTime;

        if (timer <= 5f)
        {
            return;
        }

        lxvrManager.StopRecording((LXVRResult result) => OnRecordingStopCallback(result, curState));
    }
Пример #2
0
        /*
         * UDP에서 PC와 연결 확인되면 TCP실행
         */
        private void TCP()
        {
            TcpListener listener = new TcpListener(IPAddress.Any, 7001);

            listener.Start();
            byte[] buff   = new byte[1000000];
            byte[] D      = null; //buff로 받아서 D에서 통합
            int    size   = 0;    //데이터의 크기
            int    count  = 0;    //버퍼의 개수
            int    param1 = -1;
            int    param2 = -1;
            bool   toggle = false; //data 전송중인지 확인
            string name   = null;

            while (TF1)
            {
                TcpClient     tc     = listener.AcceptTcpClient();
                NetworkStream stream = tc.GetStream();
                int           n;

                while ((n = stream.Read(buff, 0, buff.Length)) > 0)
                {
                    string data = Encoding.UTF8.GetString(buff, 0, n);
                    Debug.Log(data);

                    string[] command = data.Split(' ');
                    //데이터 수신 시작
                    if (command[0].Equals("data"))
                    {
                        Debug.Log("1");
                        name   = command[1];
                        size   = Convert.ToInt32(command[4]);
                        param1 = Convert.ToInt32(command[2]);
                        param2 = Convert.ToInt32(command[3]);
                        D      = new byte[size];
                        Debug.Log(size);
                        toggle = true;
                        UI.instance.setdatasize(size);
                        UI.instance.setparam1(-1);
                        UI.instance.setparam2(-1);
                        UI.instance.setstatus(UI.testStatus.Loading);
                    }
                    //뇌파 녹화 시작
                    else if (command[0].Equals("start"))
                    {
                        lxvrManager.StartRecording(UI.instance.getstatus().ToString(),
                                                   name,
                                                   false,
                                                   (LXVRResult result) => OnRecordingStartCallback(result));
                    }
                    //뇌파 녹화 중지
                    else if (command[0].Equals("stop"))
                    {
                        lxvrManager.StopRecording((LXVRResult result) => OnRecordingStopCallback(result));
                    }
                    //분석 로딩
                    else if (command[0].Equals("loading"))
                    {
                        /*
                         * 계획 : UIclass에 결과 전송
                         */
                        UI.instance.setparam1(-1);
                        UI.instance.setparam2(-1);
                        UI.instance.setstatus(UI.testStatus.Loading);
                    }
                    //결과 수신
                    else if (command[0].Equals("result"))
                    {
                        /*
                         * 계획 : UIclass에 결과 전송
                         */
                        UI.instance.setparam1(-1);
                        UI.instance.setparam2(-1);
                        UI.instance.setstatus(UI.testStatus.Result);
                    }
                    //데이터 수신 중지
                    else if (command[0].Equals("end"))
                    {
                        Debug.Log(name);
                        toggle = false;
                        size   = 0;
                        count  = 0;
                        Data   = D;
                        string[] file = name.Split('.');
                        Debug.Log(name);
                        Debug.Log(file);
                        Debug.Log(file[file.Length - 1]);
                        if (file[file.Length - 1].Equals("jpg"))
                        {
                            UI.instance.setparam1(param1);
                            UI.instance.setparam2(param2);
                            UI.instance.setstatus(UI.testStatus.Image);
                        }
                        else if (file[file.Length - 1].Equals("mp4"))
                        {
                            UI.instance.setparam1(param1);
                            UI.instance.setparam2(param2);
                            UI.instance.setstatus(UI.testStatus.Video);
                        }
                        param1 = -1;
                        param2 = -1;
                        UI.instance.setdatasize(0);
                        UI.instance.setloaded(0);
                        UI.instance.setprogress(0);
                    }
                    //데이터 수신
                    else if (toggle)
                    {
                        Debug.Log(toggle);
                        for (int i = 0; i < n; i++)
                        {
                            D[count] = buff[i];
                            count++;
                        }
                        UI.instance.setloaded(count);
                        int pro = count / (size / 100);
                        UI.instance.setprogress(pro);
                    }
                }
                stream.Close();
                tc.Close();
            }
        }