/// <summary>
 /// Adds the received <see cref="GenericDeviceData"/> to the <see cref="DevicesData"/> dictionary.
 /// </summary>
 /// <param name="key">The key to be used in the <see cref="DevicesData"/> dictionary.</param>
 /// <param name="deviceData">The <see cref="GenericDeviceData"/> to be added to the <see cref="DevicesData"/> dictionary.</param>
 protected virtual void AddDeviceDataToList(string key, GenericDeviceData deviceData)
 {
     if (DevicesData.ContainsKey(key) == false)
     {
         DevicesData.Add(key, deviceData);
     }
 }
        /// <summary>
        /// It instantiates a Unity Object using the Prefabs list as a support. The default prefab is the prefab at index 0 of <see cref="Prefabs"/> but it can be redefined as any other device when calling this function.
        /// </summary>
        /// <param name="genericDeviceData">The <see cref="GenericDeviceData"/> containing the data for this device.</param>
        /// <param name="index">The index for the <see cref="Prefabs"/> list.</param>
        protected virtual void InstantiateUnityObject(GenericDeviceData genericDeviceData, int index = 0)
        {
            var prefabInstance = Instantiate(Prefabs[index]);
            var deviceUnity    = prefabInstance.GetComponent <GenericDeviceUnity>();

            deviceUnity.SetDeviceData(genericDeviceData);
            prefabInstance.transform.SetParent(PrefabParent, false);
            genericDeviceData.UnityObject = prefabInstance;
        }
        /// <summary>
        /// Instanitiates the apropriated <see cref="GenericDeviceData"/> based on the <see cref="GenericDevice"/> received.
        /// </summary>
        /// <param name="deviceName">The <see cref="GenericDevice"/> that contains all the <see cref="StringValues"/> with the information received via UDP for this device.</param>
        /// <param name="values">The <see cref="StringValues"/> being process now.</param>
        /// <returns>The <see cref="GenericDeviceData"/> instantiated inside the function.</returns>
        public virtual GenericDeviceData CreateGenericDeviceData(string deviceName, StringValues values)
        {
            GenericDeviceData genericDeviceData;

            if (deviceName == Enums.Devices.neurosky.ToString())
            {
                genericDeviceData = new NeuroskyData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.tobiieyex.ToString())
            {
                NumberOfSamples   = 5;
                genericDeviceData = new TobiiEyeXData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.kinect.ToString())
            {
                genericDeviceData = new KinectData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.bioplux.ToString())
            {
                genericDeviceData = new BiopluxData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.oculus.ToString())
            {
                genericDeviceData = new OculusRiftData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.emotiv.ToString())
            {
                genericDeviceData = new EmotivData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.bitalino.ToString())
            {
                genericDeviceData = new BitalinoData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.zephyr.ToString())
            {
                genericDeviceData = new ZephyrData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else if (deviceName == Enums.Devices.leapmotion.ToString())
            {
                genericDeviceData = new LeapMotionData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }
            else
            {
                genericDeviceData = new GenericDeviceData(values.Id, deviceName, values)
                {
                    Controller = this
                };
            }

            return(genericDeviceData);
        }
Пример #4
0
 /// <summary>
 /// Sets the <see cref="GenericDeviceData"/> as the device received in the parameters.
 /// </summary>
 /// <param name="device">The <see cref="Abstracts.GenericDeviceData"/> that contains the Data to be used by this object.</param>
 public void SetDeviceData(GenericDeviceData device)
 {
     GenericDeviceData = device;
 }