Esempio n. 1
0
        private USBAppIntentProfile MakeUSBProfile(AppIntentProfile appIntentProfile)
        {
            USBAppIntentProfile usbProfile = new USBAppIntentProfile();

            if (appIntentProfile != null)
            {
                // Sensors
                usbProfile.sensorBitmask = 0;
                for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
                {
                    SensorId sensor = WearableConstants.SensorIds[i];

                    // Does this profile require this sensor?
                    if (appIntentProfile.GetSensorInProfile(sensor))
                    {
                        SensorFlags sensorBit = WearableTools.GetSensorFlag(sensor);
                        usbProfile.sensorBitmask |= (int)sensorBit;
                    }
                }

                // Gestures
                usbProfile.gestureBitmask = 0;
                for (int i = 0; i < WearableConstants.GestureIds.Length; i++)
                {
                    GestureId gesture = WearableConstants.GestureIds[i];

                    // Does this profile require this gesture?
                    if (appIntentProfile.GetGestureInProfile(gesture))
                    {
                        GestureFlags gestureBit = WearableTools.GetGestureFlag(gesture);
                        usbProfile.gestureBitmask |= (int)gestureBit;
                    }
                }

                usbProfile.updateIntervalBitmask = 0;
                for (int i = 0; i < WearableConstants.UpdateIntervals.Length; i++)
                {
                    SensorUpdateInterval interval = WearableConstants.UpdateIntervals[i];

                    // Does this profile require this update interval?
                    if (appIntentProfile.GetIntervalInProfile(interval))
                    {
                        int intervalBit = WearableTools.SensorUpdateIntervalToBit(interval);
                        usbProfile.updateIntervalBitmask |= intervalBit;
                    }
                }
            }

            return(usbProfile);
        }
Esempio n. 2
0
        private int GetSamplePeriodsFromAppIntentProfile(AppIntentProfile profile)
        {
            int samplePeriods = 0;

            if (profile != null)
            {
                for (int i = 0; i < WearableConstants.UpdateIntervals.Length; i++)
                {
                    if (profile.GetIntervalInProfile(WearableConstants.UpdateIntervals[i]))
                    {
                        samplePeriods |= (1 << i);
                    }
                }
            }

            return(samplePeriods);
        }
        /// <summary>
        /// Helper function to convert our AppIntentProfile to something more easily consumable
        /// by the bridge layer.
        /// </summary>
        private static BridgeAppIntentProfile CreateBridgeAppIntentProfile(AppIntentProfile appIntentProfile)
        {
            BridgeAppIntentProfile bridgeAppIntentProfile = new BridgeAppIntentProfile();
            int sensors       = 0;
            int samplePeriods = 0;
            int gestures      = 0;

            if (appIntentProfile != null)
            {
                for (int i = 0; i < WearableConstants.SENSOR_IDS.Length; i++)
                {
                    if (appIntentProfile.GetSensorInProfile(WearableConstants.SENSOR_IDS[i]))
                    {
                        sensors |= (1 << i);
                    }
                }

                for (int i = 0; i < WearableConstants.UPDATE_INTERVALS.Length; i++)
                {
                    if (appIntentProfile.GetIntervalInProfile(WearableConstants.UPDATE_INTERVALS[i]))
                    {
                        samplePeriods |= (1 << i);
                    }
                }

                for (int i = 0; i < WearableConstants.GESTURE_IDS.Length; i++)
                {
                    if (WearableConstants.GESTURE_IDS[i] == GestureId.None)
                    {
                        continue;
                    }

                    if (appIntentProfile.GetGestureInProfile(WearableConstants.GESTURE_IDS[i]))
                    {
                        gestures |= (1 << (i - 1));
                    }
                }
            }

            bridgeAppIntentProfile.sensors       = sensors;
            bridgeAppIntentProfile.samplePeriods = samplePeriods;
            bridgeAppIntentProfile.gestures      = gestures;

            return(bridgeAppIntentProfile);
        }