Exemple #1
0
    // Update is called once per frame
    private void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            TestSinglePulse();
        }

        else if (Input.GetKeyDown(startKey))
        {
            if (Input.GetKey(KeyCode.LeftControl))
            {
                startPulseThread();
            }
            else
            {
                ChannelMask channels = new ChannelMask();
                channels.setChannel((int)channel);
                channels.setChannel((int)channel2);

                ChannelList.InitCM(0
                                   , channels
                                   , new ChannelMask()
                                   , groupFrequency
                                   , channelFrequency);
            }
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            if (channel1Active)
            {
                print("Stop Channel 1");
                ChannelList.StopChannel((int)channel);
            }
            else
            {
                print("Start Channel 1");
                ChannelList.UpdateChannel((int)channel, new UpdateInfo(UpdateInfo.MODE_SINGLE
                                                                       , pulseWidth
                                                                       , milliAmps));
            }

            channel1Active = !channel1Active;
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            if (channel2Active)
            {
                print("Stop Channel 2");
                ChannelList.StopChannel((int)channel2);
            }
            else
            {
                print("Start Channel 2");
                ChannelList.UpdateChannel((int)channel2, new UpdateInfo(UpdateInfo.MODE_SINGLE
                                                                        , pulseWidth2
                                                                        , milliAmps2));
            }

            channel2Active = !channel2Active;
            //ChannelList.StopChannel((int)channel);
            //ChannelList.UpdateChannel((int)channel2, new UpdateInfo(0, pulseWidth2, milliAmps2));
        }
        else if (Input.GetKeyDown(stopKey))
        {
            if (Input.GetKey(KeyCode.LeftControl))
            {
                stopPulseThread();
            }
            else
            {
                channel1Active = false;
                channel2Active = false;
                ChannelList.Stop();
            }

            //RehaStimInterface.sendMessage(ChannelList.GetStopCommand());
        }
        else if (Input.GetKeyDown(KeyCode.KeypadPlus))
        {
            if (channel1Active)
            {
                pulseWidth += 5;
                ChannelList.UpdateChannel((int)channel, new UpdateInfo(UpdateInfo.MODE_SINGLE, pulseWidth, milliAmps));
            }
        }
        else if (Input.GetKeyDown(KeyCode.KeypadMinus))
        {
            if (channel1Active)
            {
                pulseWidth -= 5;
                ChannelList.UpdateChannel((int)channel, new UpdateInfo(UpdateInfo.MODE_SINGLE, pulseWidth, milliAmps));
            }
            //RehaStimInterface.sendMessage(ChannelList.GetStopCommand());
        }
        else if (Input.GetKeyDown(KeyCode.Keypad8))
        {
            if (channel1Active)
            {
                milliAmps += 1;
                ChannelList.UpdateChannel((int)channel, new UpdateInfo(UpdateInfo.MODE_SINGLE, pulseWidth, milliAmps));
            }
        }
        else if (Input.GetKeyDown(KeyCode.Keypad2))
        {
            if (channel1Active)
            {
                milliAmps -= 1;
                ChannelList.UpdateChannel((int)channel, new UpdateInfo(UpdateInfo.MODE_SINGLE, pulseWidth, milliAmps));
            }
            //RehaStimInterface.sendMessage(ChannelList.GetStopCommand());
        }
        //StopCoroutine("ContinuousPulse");
    }