示例#1
0
    public static void Subscribe(string Serial, string Subscriptionpath, int?Samplerate)
    {
                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "Subscribe: " + Serial + ", Subscriptionpath: " + Subscriptionpath + ", Samplerate: " + Samplerate);
        }
                #pragma warning restore CS0162

        // check correct format
        if ((Subscriptionpath == SubscriptionPath.LinearAcceleration || Subscriptionpath == SubscriptionPath.AngularVelocity || Subscriptionpath == SubscriptionPath.MagneticField) &&
            Samplerate == null)
        {
            Debug.LogError(TAG + "Subscribe, Samplerate missing");
            return;
        }
        else if ((Subscriptionpath == SubscriptionPath.HeartRate || Subscriptionpath == SubscriptionPath.Temperature) &&
                 Samplerate != null)
        {
            Debug.LogWarning(TAG + "Subscribe, ignoring Samplerate");
            Samplerate = null;
            return;
        }

                #if UNITY_ANDROID && !UNITY_EDITOR
        MovesenseDevice.AddSubscription(Serial, Subscriptionpath,
                                        new MovesenseDevice.SubscriptionSection(Samplerate,
                                                                                movesensePlugin.Call <AndroidJavaObject>("subscribe", URI_EVENTLISTENER, BuildContract(Serial, Subscriptionpath + Samplerate.ToString()),
                                                                                                                         new NotificationCallback(Serial, Subscriptionpath))));
                #elif UNITY_IOS && !UNITY_EDITOR
        SubscribeMDS(Serial, Subscriptionpath, Samplerate.ToString(), "{}", onNotification, onNotificationError);
        MovesenseDevice.AddSubscription(Serial, Subscriptionpath, new MovesenseDevice.SubscriptionSection(Samplerate));
                #elif UNITY_STANDALONE_OSX || UNITY_EDITOR
                #endif
    }