// Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                edc.SetLogging(EyeDataCollect.LoggingStatus.Active);
            }

            if (Input.GetKeyDown(KeyCode.LeftAlt))
            {
                edc.SetLogging(EyeDataCollect.LoggingStatus.Pause);                  // pause data logging
                edc.Publish();                                                       // publish to file
                edc.SetLogging(EyeDataCollect.LoggingStatus.Clear);                  // clear data log
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            switch (currentStage)
            {
            case PHAMStage.Inactive:
                taskSuccess = false;                                                    // reset task success value
                timeElapsed = 0.0f;                                                     // reset timer

                button.gameObject.GetComponent <Renderer>().material.color = Color.red; // indicate that button needs to be pressed
                if (button.GetButtonStatus())
                {
                    ColorHolder();                                                                // generate a new task
                    button.SetButtonStatus(false);                                                // reset button status
                    button.gameObject.GetComponent <Renderer>().material.color = Color.green;     // reset button color
                    currentStage = PHAMStage.Active;                                              // set the stage to active
                    logger.SetLogging(DataLogger.LoggingStatus.Active);                           // activate data logging
                    edc.SetLogging(EyeDataCollect.LoggingStatus.Active);
                }
                break;

            case PHAMStage.Active:
                timeElapsed += Time.deltaTime;      // update timer

                // get dropped / success status
                bool dropped = false;
                bool success = false;

                dropped = primitives["Cylinder"].GetComponent <DroppedObjectLogic>().GetDroppedStatus();
                success = primitives["Cylinder"].GetComponent <SuccessTaskLogic>().GetSuccessStatus();
                if (success || dropped)
                {
                    primitives["Cylinder"].GetComponent <GraspingObjectLogic>().ClearFixedJoints();
                }


                if (dropped || (timeElapsed > taskTimeout))
                {               // object was dropped, task failed, load next task
                    if (dropped)
                    {
                        Debug.Log("Object was dropped! Task failed!");
                    }
                    else
                    {
                        Debug.Log("Task timeout reached! Task failed!");
                    }

                    taskSuccess = false;                                      // set task success to false
                    ClearPHAM();                                              // reset PHAM

                    logger.SetLogging(DataLogger.LoggingStatus.Pause);        // pause data logging
                    logger.Publish();                                         // publish to file
                    logger.SetLogging(DataLogger.LoggingStatus.Clear);        // clear data log
                    edc.SetLogging(EyeDataCollect.LoggingStatus.Pause);       // pause data logging
                    edc.Publish();                                            // publish to file
                    edc.SetLogging(EyeDataCollect.LoggingStatus.Clear);       // clear data log

                    button.SetButtonStatus(false);                            // make sure button is not pressed
                    currentStage = PHAMStage.Inactive;                        // set PHAM stage to inactive
                }
                else if (success && button.GetButtonStatus())
                {                                                                           // object in the target holder, task succeeded
                    button.gameObject.GetComponent <Renderer>().material.color = Color.red; // indicate that button needs to be pressed                                        // button press signals the end of the task
                    Debug.Log("Logging successful task!");

                    // clear PHAM
                    taskSuccess = true;                                                      // set task success to true
                    ClearPHAM();                                                             // reset PHAM

                    logger.SetLogging(DataLogger.LoggingStatus.Pause);                       // pause data logging
                    logger.Publish();                                                        // publish to file
                    logger.SetLogging(DataLogger.LoggingStatus.Clear);                       // clear data log
                    edc.SetLogging(EyeDataCollect.LoggingStatus.Pause);                      // pause data logging
                    edc.Publish();                                                           // publish to file
                    edc.SetLogging(EyeDataCollect.LoggingStatus.Clear);                      // clear data log

                    button.SetButtonStatus(false);                                           // make sure button is not pressed
                    button.gameObject.GetComponent <Renderer>().material.color = Color.grey; // reset button color
                    currentStage = PHAMStage.Inactive;                                       // set PHAM stage to inactive
                }
                break;
            }
        }