예제 #1
0
        /// <summary>
        /// Override this method to implement whatever should happen with the samples...
        /// IMPORTANT: Avoid heavy processing logic within this method, update a state and use
        /// coroutines for more complexe processing tasks to distribute processing time over
        /// several frames
        /// </summary>
        /// <param name="newSample"></param>
        /// <param name="timeStamp"></param>
        protected override void Process(float[] newSample, double timeStamp)
        {
            //TODO: Use the timestamp from the sensor, which is in nanoseconds.
            EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), newSample[0]);

            LoggerController.instance.WriteLine(LogName.VariableRrInterval, ExciteOMeterManager.GetTimestampString() + "," + ExciteOMeterManager.ConvertFloatToString(newSample[0]));
        }
예제 #2
0
        /// <summary>
        /// Override this method to implement whatever should happen with the samples...
        /// IMPORTANT: Avoid heavy processing logic within this method, update a state and use
        /// coroutines for more complexe processing tasks to distribute processing time over
        /// several frames
        /// </summary>
        /// <param name="newSample"></param>
        /// <param name="timeStamp"></param>
        protected void Process2(int numSamples, int[,] newSamples, double[] timeStamps)
        //protected override void Process(int numSamples, int[,] newSamples, double[] timeStamps)
        {
            ExciteOMeterManager.DebugLog("ECG NumSamples: " + numSamples);

            // pull as long samples are available
            for (int i = 0; i < numSamples; i++)
            {
                if (newSamples[0, i] > 1.0e7)  // Check values with bad parsing
                {
                    ExciteOMeterManager.DebugLog("Error parsing value: " + BitConverter.ToString(BitConverter.GetBytes(newSamples[0, i])) + ", " + newSamples[0, i].ToString("F2"));
                    continue;
                }
                else
                {
                    EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), newSamples[0, i]);
                    LoggerController.instance.WriteLine(LogName.VariableRawECG, ExciteOMeterManager.GetTimestampString() + "," + newSamples[0, i].ToString("F0") + "," + newSamples[0, i].ToString("F0"));
                }
            }

            // Debug.Log($"Receiving from stream {StreamName}, first sample {newSample[0]}");

            //TODO: The event only sends float[], all samples need to be parsed to float

            // EoM_Events.Send_OnDataReceived(VariableType, new float[1]{(float) newSample[0]});
            //LoggerController.instance.WriteLine(LogName.VariableRawECG, timestamp.ToString("F0") + "," + newSample[0].ToString("F0"));
        }
예제 #3
0
 private void ShowElapsedSessionTime()
 {
     if (sessionTimeParent.activeSelf)
     {
         sessionTimeText.text = ExciteOMeterManager.GetTimestampString(1);
     }
 }
예제 #4
0
        /// <summary>
        /// Override this method to implement whatever should happen with the samples...
        /// IMPORTANT: Avoid heavy processing logic within this method, update a state and use
        /// coroutines for more complexe processing tasks to distribute processing time over
        /// several frames
        /// </summary>
        /// <param name="newSample"></param>
        /// <param name="timeStamp"></param>
        protected override void Process(short[] newSample, double timeStamp)
        {
            //TODO: The event only sends float[], all samples need to be parsed to float
            EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), (float)newSample[0]);

            LoggerController.instance.WriteLine(LogName.VariableHeartRate, ExciteOMeterManager.GetTimestampString() + "," + ExciteOMeterManager.ConvertFloatToString(newSample[0], 0));
        }
예제 #5
0
        // Update is called once per frame
        void Update()
        {
            if (!active)
            {
                return;
            }

            // Timer control
            elapsedTime += Time.deltaTime;

            // Emulate connection disconnection HR
            if (sendHR && !previousSendHR)
            {
                EoM_Events.Send_OnStreamConnected(DataType.HeartRate);
            }
            else if (!sendHR && previousSendHR)
            {
                EoM_Events.Send_OnStreamDisconnected(DataType.HeartRate);
            }

            // Emulate connection disconnection RRi
            if (sendRrI && !previousSendRRi)
            {
                EoM_Events.Send_OnStreamConnected(DataType.RRInterval);
            }
            else if (!sendRrI && previousSendRRi)
            {
                EoM_Events.Send_OnStreamDisconnected(DataType.RRInterval);
            }


            // Send data each "sendingPeriod"
            if (elapsedTime >= sendingPeriod)
            {
                // Reset timer for next event
                elapsedTime = 0.0f;

                // Calculate new random values
                randomVariation = Random.Range(-variance, variance);

                // Setup new random values. If HR increases, RRi should decrease.
                HR  += HR * randomVariation;
                RRi -= RRi * randomVariation * Random.Range(1.0f, 3.0f);

                // Send events
                float HRf = (float)Mathf.RoundToInt(HR);
                EoM_Events.Send_OnDataReceived(DataType.HeartRate, ExciteOMeterManager.GetTimestamp(), HRf);
                LoggerController.instance.WriteLine(LogName.VariableHeartRate, ExciteOMeterManager.GetTimestampString() + "," + HR.ToString("F0"));

                EoM_Events.Send_OnDataReceived(DataType.RRInterval, ExciteOMeterManager.GetTimestamp(), RRi);
                LoggerController.instance.WriteLine(LogName.VariableRrInterval, ExciteOMeterManager.GetTimestampString() + "," + RRi.ToString("F3"));
            }

            // To detect changes in runtime
            previousSendHR  = sendHR;
            previousSendRRi = sendRrI;
        }
예제 #6
0
        ////// MARKERS UI
        public void CreateManualMarker(string defaultText, MarkerLabel markerLabel = MarkerLabel.CUSTOM_MARKER)
        {
            EoM_Events.Send_OnStringReceived(DataType.ManualMarkers, ExciteOMeterManager.GetTimestamp(), defaultText);
            LogMessageUI.instance.WriteConsoleText("New custom marker at " + ExciteOMeterManager.GetTimestampString(2) + " with message " + defaultText);
            GameObject           go     = Instantiate(instanceMarkerPrefab, markersParent);
            CustomMarkerScriptUI script = go.GetComponent <CustomMarkerScriptUI>();

            script.Setup(ExciteOMeterManager.GetTimestamp(), defaultText, markerLabel);
            // sessionMarkers.Add(script); // Used to keep record of existing session markers
            LoggerController.instance.SaveScreenshot();
        }
예제 #7
0
        // In case it is inheriting from InletIntSample instead of InletIntChunk
        // protected void Process2(int[] newSample, double timestamp)
        protected override void Process(int[] newSample, double timestamp)
        {
            // Debug.Log($"Receiving from stream {StreamName}, first sample {newSample[0]}");

            //TODO: The event only sends float[], all samples need to be parsed to float

            if (newSample[0] > 1.0e7)  // Check values with bad parsing
            {
                Debug.Log("Error parsing value ECG: " + BitConverter.ToString(BitConverter.GetBytes(newSample[0])) + ", " + newSample[0].ToString("F2"));
            }
            else
            {
                EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), newSample[0]);
                LoggerController.instance.WriteLine(LogName.VariableRawECG, ExciteOMeterManager.GetTimestampString() + "," + newSample[0].ToString("F0"));
            }
        }
예제 #8
0
        /// <summary>
        /// Override this method to implement whatever should happen with the samples...
        /// IMPORTANT: Avoid heavy processing logic within this method, update a state and use
        /// coroutines for more complexe processing tasks to distribute processing time over
        /// several frames
        /// </summary>
        /// <param name="newSample"></param>
        /// <param name="timeStamp"></param>
        protected override void Process(int[] newSample, double timestamp)
        {
            //Assuming that a sample contains at least 3 values for x,y,z
            // Debug.Log($"Receiving from stream {StreamName}, first sample {newSample[0]}");

            if (newSample[0] > 1.0e7)  // Check values with bad parsing
            {
                ExciteOMeterManager.DebugLog("Error parsing value ACC: " + BitConverter.ToString(BitConverter.GetBytes(newSample[0])) + ", " + newSample[0].ToString("F2"));
            }
            else
            {
                //EoM_Events.Send_OnDataReceived(VariableType, new float[3]{(float) newSample[0], (float) newSample[1], (float) newSample[2]});
                // TODO: The event for ACC should be a different delegate receiving float[] instead of single float.
                EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), (float)newSample[0]);
                EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), (float)newSample[1]);
                EoM_Events.Send_OnDataReceived(VariableType, ExciteOMeterManager.GetTimestamp(), (float)newSample[2]);

                LoggerController.instance.WriteLine(LogName.VariableRawACC, ExciteOMeterManager.GetTimestampString() + "," + newSample[0].ToString("F0") + "," + newSample[1].ToString("F0") + "," + newSample[2].ToString("F0"));
            }
        }
예제 #9
0
        public void FixedUpdate()
        {
            if (isConfigured && ExciteOMeterManager.currentlyRecordingSession)
            {
                // Timer control
                elapsedTime += Time.fixedDeltaTime;

                // Send data each "sendingPeriod"
                if (elapsedTime >= sendingPeriod)
                {
                    // Reset timer for next event
                    elapsedTime = 0.0f;
                    // Define array
                    transformArray[0] = objectToTrack.position.x;
                    transformArray[1] = objectToTrack.position.y;
                    transformArray[2] = objectToTrack.position.z;
                    transformArray[3] = objectToTrack.localRotation.w;    // Quaternion without axis.
                    transformArray[4] = objectToTrack.localRotation.x;    // Q in the axis i
                    transformArray[5] = objectToTrack.localRotation.y;    // Q in the axis j
                    transformArray[6] = objectToTrack.localRotation.z;    // Q in the axis k
                    transformArray[7] = objectToTrack.localEulerAngles.x; // Pitch (up-down)
                    transformArray[8] = objectToTrack.localEulerAngles.y; // Yaw (left-right)
                    transformArray[9] = objectToTrack.localEulerAngles.z; // Roll (towards shoulders)

                    // Create string to save in CSV
                    transformArrayText = "";
                    foreach (float v in transformArray)
                    {
                        transformArrayText += "," + ExciteOMeterManager.ConvertFloatToString(v, 4);
                    }

                    logIsWriting = LoggerController.instance.WriteLine(logToWrite, ExciteOMeterManager.GetTimestampString() + transformArrayText);
                    if (!logIsWriting)
                    {
                        Debug.LogWarning("Error writing movement data. Please setup LoggerController with a file with LogID is" + logToWrite.ToString());
                    }

                    //Debug.Log("Sending Movement from " + gameObject.name + " > " + transformArrayText);

                    // Send an event with the multidimensional data for the receivers taht can handle multidimensionality
                    EoM_Events.Send_OnDataArrayReceived(DataType.Headset_array, ExciteOMeterManager.GetTimestamp(), transformArray);

                    // Send values individually, because they need to be stored in the .json file as unidimensional data, so that they can be visualized

                    // --------- TODO
                    //// Visualizer is designed to analyze unidimensional data, therefore multidimensional needs to be sent one by one to the system
                    //StartCoroutine(SendDataEventsMovement(ExciteOMeterManager.GetTimestamp()));
                    // BUG: Sending events from the coroutine does not seem to be received...
                    // ---------
                    // If the above works, delete the remaining code!! ----------------------
                    if (transformArray.Length != typesTransformArray.Length)
                    {
                        Debug.LogError("The movement arrays are not the same length");
                    }

                    for (int i = 0; i < transformArray.Length; i++)
                    {
                        EoM_Events.Send_OnDataReceived(typesTransformArray[i], ExciteOMeterManager.GetTimestamp(), transformArray[i]);
                    }
                    /// --------------------------------------------------------
                }
            }
        }