Exemple #1
0
    // private void Awake() {
    //  buttonOn = Resources.Load<Sprite>("Sprites/Button_On");
    //  buttonOff = Resources.Load<Sprite>("Sprites/Button_Off");
    // }
    private void Start()
    {
                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "Start");
        }
                #pragma warning restore CS0162
        isButtonVisualizePressed = false;

        // refresh sensorlist
        RefreshScrollViewContentConnectedDevices(true);

        // refresh subscriptionlist
        RefreshPanelSubscription(0, null);

        // ButtonVisualize gets active, if any Subscription is active
        if (MovesenseDevice.isAnySubscribed(SubscriptionPath.AngularVelocity, SubscriptionPath.LinearAcceleration))
        {
            buttonVisualize.gameObject.SetActive(true);
        }
        else
        {
            buttonVisualize.gameObject.SetActive(false);
        }

        // attach event
        MovesenseController.Event += OnMovesenseControllerCallbackEvent;
    }
Exemple #2
0
    public void OnClickButtonSubscribe(int index)
    {
                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "OnClickButtonSubscribe, Button: " + buttonsSubscription[index].name);
        }
                #pragma warning restore CS0162

        // Toggle state
        bool isOn = (buttonsSubscription[index].image.sprite.name.Split('_')[1] == "On") ? true : false;
        buttonsSubscription[index].image.sprite = isOn?buttonOff:buttonOn;
        isOn = !isOn;

        string serial = MovesenseDevice.Devices[connectedElementHighlitedIndex].Serial;

        string subscriptionPath = null;
        int?   sampleRate       = null;
        string subscriptionChar = null;         // only for logging

        switch (index)
        {
        case 0:
            subscriptionPath = SubscriptionPath.LinearAcceleration;
            sampleRate       = SampleRate.slowest;
            subscriptionChar = "LinearAcceleration";
            break;

        case 1:
            subscriptionPath = SubscriptionPath.AngularVelocity;
            sampleRate       = SampleRate.slowest;
            subscriptionChar = "AngularVelocity";
            break;

        case 2:
            subscriptionPath = SubscriptionPath.MagneticField;
            sampleRate       = SampleRate.slowest;
            subscriptionChar = "MagneticField";
            break;

        case 3:
            subscriptionPath = SubscriptionPath.HeartRate;
            subscriptionChar = "HeartRate";
            break;

        case 4:
            subscriptionPath = SubscriptionPath.Temperature;
            subscriptionChar = "Temperature";
            break;
        }

                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "onClickButtonSubscribe, " + (isOn ? "" : "un") + "subscribe " + subscriptionChar + " for " + serial);
        }
                #pragma warning restore CS0162

        if (isOn)
        {
            MovesenseController.Subscribe(serial, subscriptionPath, sampleRate);
        }
        else
        {
            MovesenseController.UnSubscribe(serial, subscriptionPath);
            // clear values
            Invoke("RefreshPanelSubscriptionDelayed", 0.2F);
        }

        // ButtonVisualize gets active, if any Subscription is active
        if (MovesenseDevice.isAnySubscribed(SubscriptionPath.AngularVelocity, SubscriptionPath.LinearAcceleration))
        {
            buttonVisualize.gameObject.SetActive(true);
        }
        else
        {
            buttonVisualize.gameObject.SetActive(false);
        }
    }