Пример #1
0
        /// <summary>
        /// Devices in View of Self - This method computes the devices in the view of the calling device based on it's internal field of view angles
        /// </summary>
        /// <param name="success">Success Handler</param>
        /// <param name="failure">Failure Handler</param>
        public void GetDevicesInView(MSEDeviceCollectionHandler success, MSEErrorHandler failure)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("identifier", this.intAirAct.OwnDevice.Name);

            CallIntAirActRoute(Routes.GetAllDevicesInViewRoute, parameters, success, failure);
        }
Пример #2
0
        /// <summary>
        /// Gets the nearest Device within a certain range of the calling device
        /// </summary>
        /// <param name="rangeInMeters">Range in Meters that the returned device will be within</param>
        /// <param name="success">Success Handler</param>
        /// <param name="failure">Failure Handler</param>
        public void GetNearestDeviceInRange(float rangeInMeters, MSESingleDeviceHandler success, MSEErrorHandler failure)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("identifier", this.intAirAct.OwnDevice.Name);
            parameters.Add("range", rangeInMeters.ToString());

            CallIntAirActRoute(Routes.GetNearestDeviceInRangeRoute, parameters, success, failure);
        }
Пример #3
0
 /// <summary>
 /// This method returns all the devices currently recognized by the locator
 /// </summary>
 /// <param name="success">Success Handler</param>
 /// <param name="failure">Failure Handler</param>
 public void GetDevicesInSystem(MSEDeviceCollectionHandler success, MSEErrorHandler failure)
 {
     Dictionary<string, string> parameters = new Dictionary<string, string>();
     CallIntAirActRoute(Routes.GetAllDeviceInfoRoute, parameters, success, failure);
 }
Пример #4
0
        private void CallIntAirActRoute(IARoute route, Dictionary<string, string> parameters, Delegate successGeneric, MSEErrorHandler failure)
        {
            //Setup Routes with Device in View
            IARequest request = new IARequest(route);

            //Add Parameters
            foreach (KeyValuePair<string, string> pair in parameters)
                request.Parameters[pair.Key] = pair.Value;

            //Get all devices that support this route
            IEnumerable devicesSupportingRoute = this.intAirAct.DevicesSupportingRoute(route);

            bool sentToServer = false;

            //Request Devices in View
            foreach (IADevice device in devicesSupportingRoute)
            {
                sentToServer = true;

                this.intAirAct.SendRequest(request, device, delegate(IAResponse response, Exception exception)
                {
                    if (exception != null)
                    {
                        failure(exception);
                    }

                    // QUESTION - Is this the same as saying if(successGeneric is MSEDeviceCollectionHandler)
                    if (successGeneric.GetType() == typeof(MSEDeviceCollectionHandler))
                    {
                        // Handle the response as if response was a collection
                        MSEDeviceCollectionHandler success = (MSEDeviceCollectionHandler)successGeneric;
                        List<MSEDevice> deviceList = Util.DeserializeIntoList(response.BodyAsString());
                        Util.CompleteDeviceListInformation(deviceList, this.intAirAct);

                        success(deviceList);
                        return;

                    }
                    else if(successGeneric.GetType() == typeof(MSESingleDeviceHandler))
                    {
                        // Handle the response as if response was a single device
                        MSESingleDeviceHandler success = (MSESingleDeviceHandler)successGeneric;
                        MSEDevice result = Util.DeserializeSingleDevice(response.BodyAsString());
                        Util.CompleteDeviceInformation(result, this.intAirAct);

                        success(result);
                        return;
                    }

                });

            }

            // If sentToServer is false, that means there was no devices capable of handling the route. This could mean that no devices can handle the route, or it just hasn't been found yet
            // I would normally use IEnumerable.Count, but that doesn't exist
            if (sentToServer == false)
            {
                failure(new Exception("MSE Error - There are no Devices discovered on the Network that can handle the " + route.Action + " " + route.Resource + " request. Is your Locator Server running and visible on the network?"));
                return;
            }
        }
Пример #5
0
        public void UpdateDeviceOrientation(MSEDevice device, MSESuccessHandler success, MSEErrorHandler failure)
        {
            IARequest request = new IARequest(Routes.SetOrientationRoute);
            request.SetBodyWithString(device.Orientation.Value.ToString());
            request.Parameters["identifier"] = device.Identifier;

            IEnumerable devicesSupportingRoutes = this.intAirAct.DevicesSupportingRoute(Routes.SetOrientationRoute);
            foreach (IADevice iaDevice in devicesSupportingRoutes)
            {
                this.intAirAct.SendRequest(request, iaDevice, delegate(IAResponse response, Exception exception)
                {
                    if (exception != null)
                    {
                        failure(exception);
                        return;
                    }
                    else
                    {
                        success();
                    }
                });

                break;
            }
        }
Пример #6
0
        /// <summary>
        /// Notify the server of the device's current Location. Intended for use with stationary devices, since mobile devices can't
        /// determine their own location in the room.
        /// </summary>
        /// <param name="device">The Identifier and Location properties of this MSEDevice will be used for the update.</param>
        /// <param name="success"></param>
        /// <param name="failure"></param>
        public void UpdateDeviceLocation(MSEDevice device, MSESuccessHandler success, MSEErrorHandler failure)
        {
            IARequest updateRequest = new IARequest(Routes.SetLocationRoute);
            updateRequest.SetBodyWith(new IntermediatePoint(device.Location.Value));
            updateRequest.Parameters["identifier"] = device.Identifier;

            IEnumerable devicesSupportingRoutes = this.intAirAct.DevicesSupportingRoute(Routes.SetLocationRoute);
            foreach (IADevice iaDevice in devicesSupportingRoutes)
            {
                this.intAirAct.SendRequest(updateRequest, iaDevice, delegate(IAResponse response, Exception exception)
                {
                    if (exception != null)
                    {
                        failure(exception);
                        return;
                    }
                    else
                    {
                        success();
                    }
                });

                // Break, so that we only send the update to one server
                // How our system should function if there are multiple servers is undefined ...
                break;
            }
        }
Пример #7
0
        /// <summary>
        /// This method takes an MSEDevice object and 'locates' it. This could be used if the MSEDevice did not have an initial location (i.e. the location and orientation values are nil. Or if the device has become stale and requires an update
        /// </summary>
        /// <param name="device">Device to be located</param>
        /// <param name="success">Success Handler</param>
        /// <param name="failure">Failure Handler</param>
        public void Locate(MSEDevice device, MSESingleDeviceHandler success, MSEErrorHandler failure)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("identifier", this.intAirAct.OwnDevice.Name);

            CallIntAirActRoute(Routes.GetDeviceInfoRoute, parameters, success, failure);
        }