Ejemplo n.º 1
0
 public void sendPulse()
 {
     print("test");
     for (int i = 0; i < pulseCount; i++)
     {
         SinglePulse.sendSinglePulse(channel, pulseWidth, pulseCurrent);
     }
 }
Ejemplo n.º 2
0
    // Feedback of Cube on touch
    public void VisualFeeback(GameObject GO)
    {
        if (!startedQuestionnaire)
        {
            // disable both possible colliders
            GO.gameObject.GetComponent <SphereCollider>().enabled = false; // no collision with the cube anymore

            // three feedback conditions in total
            // 1: visual only
            GO.gameObject.GetComponent <Renderer>().material.color = Color.red;

            // calculate reaction time between stimulus onset and touching the stimulus cubes
            reaction_time = actualTime - reaction_start_time;
        }

        // 2: vibrotactile
        if (vibroFeedbackCondition)
        {
            vibroFeedback = true;
            arduino.analogWrite(3, vibroStrength); // motor ON
            elapsed = 0;
            if (!startedQuestionnaire)
            {
                GUIControl.marker.Write("box:touched;condition:" + feedback_type + ";vibroFeedback:on;reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6) + ";vibro_duration:" + vibroFeedbackDuration);
                Debug.Log("box:touched;condition:" + feedback_type + ";vibroFeedback:on;reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6) + ";vibro_duration:" + vibroFeedbackDuration);
            }
        }

        // 3: EMS/FES
        if (emsFeedbackCondition)
        {
            for (int i = 0; i < pulseCount; i++)
            {
                SinglePulse.sendSinglePulse(1, emsWidth, emsCurrent);
            }
            if (!startedQuestionnaire)
            {
                GUIControl.marker.Write("box:touched;condition:" + feedback_type + ";emsFeedback:on;reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6) + ";emsCurrent:" + emsCurrent + ";emsWidth:" + emsWidth + ";pulseCount:" + pulseCount);
                Debug.Log("box:touched;condition:" + feedback_type + ";emsFeedback:on;reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6) + ";emsCurrent:" + emsCurrent + ";emsWidth:" + emsWidth + ";pulseCount:" + pulseCount);
            }
        }
        else
        {
            if (!startedQuestionnaire)
            {
                // LSL marking feedback type and intensity, todo correct make this better
                GUIControl.marker.Write("box:touched;condition:" + feedback_type + ";reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6));
                Debug.Log("box:touched;condition:" + feedback_type + ";reaction_time:" + reaction_time + ";trial_nr:" + (((currentBlock - 1) * 100) + trialSeqCounter + 1) + ";normal_or_conflict:" + normConflict + ";cube:" + GO + ";isiTime:" + (isiTime + 6));
            }
        }

        if (!startedQuestionnaire)
        {
            // continue with next trial
            nextTrial();
        }
    }
Ejemplo n.º 3
0
    public static bool sendSinglePulse(int channel_number, int pulse_width, int pulse_current)
    {
        if (channel_number == 0)
        {
            return(false);
        }

        byte[] command = SinglePulse.getCommand(channel_number, pulse_width, pulse_current);
        RehaStimInterface.sendMessage(command);

        return(true);
    }
    public static bool sendSinglePulse(Channels channel_number, int pulse_width, int pulse_current)
    {
        if (channel_number == Channels.ChannelNone)
        {
            return(false);
        }

        byte[] command = SinglePulse.getCommand((int)channel_number, pulse_width, pulse_current);
        RehaStimInterface.sendMessage(command);

        return(true);

        Debug.Log("single pulse more channel");
    }
Ejemplo n.º 5
0
    public IEnumerator stimulateBurst(StimulationInfo[] infos, int duration)
    {
        System.DateTime stopTime = System.DateTime.Now.AddMilliseconds(duration);

        while (stopTime > System.DateTime.Now)
        {
            Stop();
            foreach (var info in infos)
            {
                Channels channel = GetChannel(info.part, info.side);
                SinglePulse.sendSinglePulse(channel, info.width, info.current);
            }

            yield return(null);
        }
    }
Ejemplo n.º 6
0
 private void pulseThreadLoop()
 {
     while (isRunning)
     {
         //send a single pulse
         if ((stopwatch.ElapsedMilliseconds >= 1000 / pulseLoopFrequency))
         {
             SinglePulse.sendSinglePulse(Channels.Channel1, 150, 15);
             //UnityEngine.Debug.Log(SinglePulse.stopwatch.ElapsedMilliseconds);
             stopwatch.Reset();
             stopwatch.Start();
         }
         //Thread.Sleep((int)(1000/pulseLoopFrequency));
         // UnityEngine.Debug.Log(SinglePulse.stopwatch.ElapsedMilliseconds);
     }
 }
Ejemplo n.º 7
0
    public void stimulateSinglePulse(Part part, Side side, int width, int current)
    {
        Stop();

        //update bodypart
        Constants.Channels channel = GetChannel(part, side);

        if (channel == Constants.Channels.ChannelNone)
        {
            return;
        }

        for (int i = 0; i < pulseCount; i++)
        {
            SinglePulse.sendSinglePulse(channel, width, current);
        }
    }
Ejemplo n.º 8
0
 private void TestSinglePulse()
 {
     SinglePulse.sendSinglePulse(Channels.Channel1, 200, 10);
     Debug.Log("send single pulse");
 }
Ejemplo n.º 9
0
    /*public void stimulateVibrato()
     * {
     * Stop();
     *
     *      Debug.Log("vibrato subroutine");
     *
     * for (int i = 0; i < 20; i++)
     * {
     *  SinglePulse.sendSinglePulse(1, 200, 9);
     *              yield return new WaitForSeconds(0.1);
     *      }
     *      yield return new WaitForSeconds(0.3);
     *      for (int i = 0; i < 20; i++)
     * {
     *  SinglePulse.sendSinglePulse(2, 200, 12);
     *              yield return new WaitForSeconds(0.1);
     *      }
     *
     * }*/

    public IEnumerator stimulateVibrato()
    {
        Stop();
        while (stage == 1)
        {
            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 7);
                yield return(new WaitForSeconds(0.003f));
            }

            yield return(new WaitForSeconds(0.08f));

            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 9);
                yield return(new WaitForSeconds(0.003f));
            }

            yield return(new WaitForSeconds(0.08f));

            yield return(new WaitForSeconds(0.08f));
        }

        while (stage == 2)
        {
            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 8);
                yield return(new WaitForSeconds(0.003f));
            }

            yield return(new WaitForSeconds(0.07f));

            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 11);
                yield return(new WaitForSeconds(0.003f));
            }

            yield return(new WaitForSeconds(0.07f));

            yield return(new WaitForSeconds(0.07f));
        }

        while (stage == 3)
        {
            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 9);
                yield return(new WaitForSeconds(0.0025f));
            }

            yield return(new WaitForSeconds(0.06f));

            for (int i = 0; i < 20; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 12);
                yield return(new WaitForSeconds(0.0025f));
            }

            yield return(new WaitForSeconds(0.06f));

            yield return(new WaitForSeconds(0.06f));
        }


        while (stage == 4)
        {
            for (int i = 0; i < 15; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 10);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.04f));

            for (int i = 0; i < 15; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 12);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.04f));

            yield return(new WaitForSeconds(0.04f));
        }

        while (stage == 5)
        {
            for (int i = 0; i < 12; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 10);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            for (int i = 0; i < 12; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 13);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            yield return(new WaitForSeconds(0.03f));
        }

        while (stage == 6)
        {
            for (int i = 0; i < 8; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 11);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            for (int i = 0; i < 8; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 14);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            yield return(new WaitForSeconds(0.03f));
        }

        while (stage == 7)
        {
            for (int i = 0; i < 8; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 11);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            for (int i = 0; i < 8; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 15);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.025f));

            yield return(new WaitForSeconds(0.025f));
        }

        while (stage == 8)
        {
            for (int i = 0; i < 5; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 12);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.03f));

            for (int i = 0; i < 5; i++)
            {
                SinglePulse.sendSinglePulse(2, 200, 15);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.02f));

            yield return(new WaitForSeconds(0.02f));
        }

        while (stage == 9)
        {
            for (int i = 0; i < 5; i++)
            {
                SinglePulse.sendSinglePulse(1, 200, 12);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.01f));

            for (int i = 0; i < 5; i++)
            {
                SinglePulse.sendSinglePulse(2, 250, 15);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.01f));

            yield return(new WaitForSeconds(0.01f));
        }

        while (stage == 10)
        {
            for (int i = 0; i < 4; i++)
            {
                SinglePulse.sendSinglePulse(1, 225, 12);
                yield return(new WaitForSeconds(0.001f));
            }

            //yield return new WaitForSeconds(0.01f);

            for (int i = 0; i < 8; i++)
            {
                SinglePulse.sendSinglePulse(2, 250, 15);
                yield return(new WaitForSeconds(0.001f));
            }

            yield return(new WaitForSeconds(0.01f));

            //yield return new WaitForSeconds(0.01f);
        }


        //yield return null;
    }