Пример #1
0
        /// <summary>
        /// Saves the metadata associated with a single area description unique ID.
        /// </summary>
        /// <returns>
        /// Returns TANGO_SUCCESS on successful save, or TANGO_ERROR on failure, or if the service needs to be
        /// initialized.
        /// </returns>
        /// <param name="adfUnityHolder">The metadata and associated UUID to save.</param>
        public static int SaveAreaDescriptionMetaData(UUIDUnityHolder adfUnityHolder)
        {
            if (adfUnityHolder == null)
            {
                Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
                return(Common.ErrorType.TANGO_ERROR);
            }
            if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
            {
                Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
                return(Common.ErrorType.TANGO_ERROR);
            }
            if (adfUnityHolder.uuidMetaData.meta_data_pointer == IntPtr.Zero)
            {
                Debug.Log(CLASS_NAME + "metadata pointer is null, cannot save metadata to this ADF!");
                return(Common.ErrorType.TANGO_ERROR);
            }
            Debug.Log("UUID being saved is: " + adfUnityHolder.GetStringDataUUID());
            int returnValue = PoseProviderAPI.TangoService_saveAreaDescriptionMetadata(adfUnityHolder.GetStringDataUUID(), adfUnityHolder.uuidMetaData.meta_data_pointer);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log(CLASS_NAME + "Could not save metadata to the ADF!");
            }
            return(returnValue);
        }
Пример #2
0
        /// <summary>
        /// Saves an area description to device based on the UUID object contained in the adfID object holder.
        /// </summary>
        /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if saving was successfull.</returns>
        /// <param name="adfID">The UUIDUnityHolder object that contains the desired UUID object.</param>
        public static int SaveAreaDescription(UUIDUnityHolder adfUnityHolder)
        {
            // is learning mode on
            // are we localized?

            if (adfUnityHolder == null)
            {
                Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
                return(Common.ErrorType.TANGO_ERROR);
            }
            IntPtr idData      = Marshal.AllocHGlobal(Common.UUID_LENGTH);
            int    returnValue = PoseProviderAPI.TangoService_saveAreaDescription(idData);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log(CLASS_NAME + ".SaveAreaDescripton() Could not save area description with ID: " + adfUnityHolder.GetStringDataUUID());
            }
            else
            {
                byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
                Marshal.Copy(idData, tempDataBuffer, 0, Common.UUID_LENGTH);
                adfUnityHolder.SetDataUUID(tempDataBuffer);
            }
            return(returnValue);
        }
Пример #3
0
        /// <summary>
        /// Takes care of importing a adf file from the specified path. Important: make sure that the filepath
        /// does not contain ADF files already present on device, otherwise it will return an error, as duplicates
        /// can't be imported.
        /// </summary>
        /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if the UUID was imported successfully.</returns>
        /// <param name="adfID">The <c>UUIDUnityHolder</c> object that will contain information about the retrieved ADF.</param>
        /// <param name="filePath">File path containing the ADF we want to export.</param>
        public static int ImportAreaDescriptionFromFile(UUIDUnityHolder adfID, string filePath)
        {
            if (adfID == null)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                                   CLASS_NAME +
                                                   ".ImportAreaDescription() Could not  import area description. UUID Holder object specified is not initialized");
                return(Common.ErrorType.TANGO_ERROR);
            }
            IntPtr uuidHolder  = Marshal.AllocHGlobal(Common.UUID_LENGTH);
            int    returnValue = PoseProviderAPI.TangoService_importAreaDescription(filePath, uuidHolder);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR,
                                                   CLASS_NAME + ".ImportAreaDescription() Could not import area description at path: " + filePath);
            }
            else
            {
                byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
                Marshal.Copy(uuidHolder, tempDataBuffer, 0, Common.UUID_LENGTH);
                adfID.SetDataUUID(tempDataBuffer);
            }
            return(returnValue);
        }
Пример #4
0
        /// <summary>
        /// Gets the metadata handle associated with a single area description unique ID.
        /// </summary>
        /// <returns>
        /// Returns TANGO_SUCCESS on successful load of metadata, or TANGO_ERROR if the service needs to be initialized
        /// or if the metadata could not be loaded.
        /// </returns>
        /// <param name="adfUnityHolder">
        /// The TangoUUID for which to load the metadata.  On success, this function sets the pointer to raw UUID
        /// metadata which can then be extracted using AreaDescriptionMetaData_get, AreaDescriptionMetaData_get, or
        /// PopulateAreaDescriptionMetaDataKeyValues.
        /// </param>
        public static int GetAreaDescriptionMetaData(UUIDUnityHolder adfUnityHolder)
        {
            if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
            {
                Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
                return(Common.ErrorType.TANGO_ERROR);
            }
            int returnValue = PoseProviderAPI.TangoService_getAreaDescriptionMetadata(adfUnityHolder.GetStringDataUUID(), ref adfUnityHolder.uuidMetaData.meta_data_pointer);

            if (returnValue != Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log(CLASS_NAME + "Meta Data could not be loaded");
            }
            Debug.Log("GetAreaDescription return value is: " + returnValue.ToString());
            return(returnValue);
        }
 void Update () {
     if (startedSaving) {
         if(keyboard.done) {
             savedAdfHolder = new UUIDUnityHolder();
             keyboardString = keyboard.text;
             PoseProvider.SaveAreaDescription (savedAdfHolder);
             PoseProvider.GetAreaDescriptionMetaData(savedAdfHolder);
             PoseProvider.AreaDescriptionMetaData_set(Common.MetaDataKeyType.KEY_NAME, keyboardString,savedAdfHolder);
             PoseProvider.SaveAreaDescriptionMetaData(savedAdfHolder);
             
             // Null terminator will cause invalid argument in the file system.
             string uuid = savedAdfHolder.GetStringDataUUID().Replace("\0","");
             string path = Application.persistentDataPath + "/" + uuid;
             FileParser.SaveBuildingDataToPath(BuildingManager.instance.buildingList, path);
             EventManager.instance.GameDataSaved(true);
             startedSaving = false;
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Set the value of a key in a metadata.
        /// </summary>
        /// <returns>TANGO_SUCCESS if successful, else TANGO_INVALID or TANGO_ERROR.</returns>
        /// <param name="key">Key to set the value of.</param>
        /// <param name="value">Value to set.</param>
        /// <param name="adfUnityHolder">Area description + metadata holder.</param>
        public static int AreaDescriptionMetaData_set(String key, String value, UUIDUnityHolder adfUnityHolder)
        {
            if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
            {
                Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
                return(Common.ErrorType.TANGO_ERROR);
            }

            int returnValue = PoseProviderAPI.TangoAreaDescriptionMetadata_set(adfUnityHolder.uuidMetaData.meta_data_pointer, key, (uint)value.Length, value);

            if (returnValue != Tango.Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("Could not set Metadata Key, Error return value is: " + returnValue);
                return(returnValue);
            }
            else
            {
                Debug.Log("Metadata Set succesful, Key set is: " + key + " Value set is: " + value);
                return(returnValue);
            }
        }
Пример #7
0
        /// <summary>
        /// Get the value of a key from a metadata.
        /// </summary>
        /// <returns>TANGO_SUCCESS if successful, else TANGO_INVALID or TANGO_ERROR.</returns>
        /// <param name="key">Key to lookup.</param>
        /// <param name="value">On success, the value for that key.</param>
        /// <param name="adfUnityHolder">Area description + metadata holder.</param>
        public static int AreaDescriptionMetaData_get(String key, ref String value, UUIDUnityHolder adfUnityHolder)
        {
            if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
            {
                Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
                return(Common.ErrorType.TANGO_ERROR);
            }
            uint   valuesize    = 0;
            IntPtr valuePointer = IntPtr.Zero;
            int    returnValue  = PoseProviderAPI.TangoAreaDescriptionMetadata_get(adfUnityHolder.uuidMetaData.meta_data_pointer, key, ref valuesize, ref valuePointer);

            if (returnValue != Tango.Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("Could not read metadata key, Error return value is: " + returnValue);
                return(returnValue);
            }
            else
            {
                byte[] valueByteArray = new byte[valuesize];
                Marshal.Copy(valuePointer, valueByteArray, 0, (int)valuesize);
                value = System.Text.Encoding.UTF8.GetString(valueByteArray);
                return(returnValue);
            }
        }
Пример #8
0
        /// DEPRECATED: Use the AreaDescription class and AreaDescription.Metadata instead.
        /// <summary>
        /// Set the value of a key in a metadata.
        /// </summary>
        /// <returns>TANGO_SUCCESS if successful, else TANGO_INVALID or TANGO_ERROR.</returns>
        /// <param name="key">Key to set the value of.</param>
        /// <param name="value">Value to set.</param>
        /// <param name="adfUnityHolder">Area description + metadata holder.</param>
        public static int AreaDescriptionMetaData_set(String key, String value, UUIDUnityHolder adfUnityHolder)
        {
            if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
            {
                Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
                return Common.ErrorType.TANGO_ERROR;
            }

            int returnValue = PoseProviderAPI.TangoAreaDescriptionMetadata_set(adfUnityHolder.uuidMetaData.meta_data_pointer, key, (uint)value.Length, value);
            if (returnValue != Tango.Common.ErrorType.TANGO_SUCCESS)
            {
                Debug.Log("Could not set Metadata Key, Error return value is: " + returnValue);
                return returnValue;
            }
            else
            {
                Debug.Log("Metadata Set succesful, Key set is: " + key + " Value set is: " + value);
                return returnValue;
            }
        }
Пример #9
0
 /// DEPRECATED: Use the AreaDescription class and AreaDescription.Metadata instead.
 /// <summary>
 /// Get the value of a key from a metadata.
 /// </summary>
 /// <returns>TANGO_SUCCESS if successful, else TANGO_INVALID or TANGO_ERROR.</returns>
 /// <param name="key">Key to lookup.</param>
 /// <param name="value">On success, the value for that key.</param>
 /// <param name="adfUnityHolder">Area description + metadata holder.</param>
 public static int AreaDescriptionMetaData_get(String key, ref String value, UUIDUnityHolder adfUnityHolder)
 {
     if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
     {
         Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
         return Common.ErrorType.TANGO_ERROR;
     }
     uint valuesize = 0;
     IntPtr valuePointer = IntPtr.Zero;
     int returnValue = PoseProviderAPI.TangoAreaDescriptionMetadata_get(adfUnityHolder.uuidMetaData.meta_data_pointer, key, ref valuesize, ref valuePointer);
     if (returnValue != Tango.Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log("Could not read metadata key, Error return value is: " + returnValue);
         return returnValue;
     }
     else
     {
         byte[] valueByteArray = new byte[valuesize];
         Marshal.Copy(valuePointer, valueByteArray, 0, (int)valuesize);
         value = System.Text.Encoding.UTF8.GetString(valueByteArray);
         return returnValue;
     }
 }
Пример #10
0
 /// DEPRECATED: Use the AreaDescription class and AreaDescription.GetMetadata instead.
 /// <summary>
 /// Gets the metadata handle associated with a single area description unique ID.
 /// </summary>
 /// <returns>
 /// Returns TANGO_SUCCESS on successful load of metadata, or TANGO_ERROR if the service needs to be initialized
 /// or if the metadata could not be loaded.
 /// </returns>
 /// <param name="adfUnityHolder">
 /// The TangoUUID for which to load the metadata.  On success, this function sets the pointer to raw UUID
 /// metadata which can then be extracted using AreaDescriptionMetaData_get, AreaDescriptionMetaData_get, or
 /// PopulateAreaDescriptionMetaDataKeyValues.
 /// </param>
 public static int GetAreaDescriptionMetaData(UUIDUnityHolder adfUnityHolder)
 {
     if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
     {
         Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
         return Common.ErrorType.TANGO_ERROR;
     }
     int returnValue = PoseProviderAPI.TangoService_getAreaDescriptionMetadata(adfUnityHolder.GetStringDataUUID(), ref adfUnityHolder.uuidMetaData.meta_data_pointer);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + "Meta Data could not be loaded");
     }
     Debug.Log("GetAreaDescription return value is: " + returnValue.ToString());
     return returnValue;
 }
Пример #11
0
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Import an area description from a file path to the default area storage location. 
 /// 
 /// Please call ImportAreaDescriptionFromFile(string filePath) instead.
 /// The new area description will get a new ID, which will be stored in adfID.
 /// </summary>
 /// <returns><c>Common.ErrorType.TANGO_SUCCESS</c> if the UUID was imported successfully.</returns>
 /// <param name="adfID">Upon successful return, this will have the new ID.</param>
 /// <param name="filePath">File path of the area descrption to be imported.</param>
 public static int ImportAreaDescriptionFromFile(UUIDUnityHolder adfID, string filePath)
 {
     if (adfID == null)
     {
         Debug.Log(CLASS_NAME + ".ImportAreaDescription() Could not  import area description. UUID Holder object specified is not initialized");
         return Common.ErrorType.TANGO_ERROR;
     }
     IntPtr uuidHolder = Marshal.AllocHGlobal(Common.UUID_LENGTH);
     int returnValue = PoseProviderAPI.TangoService_importAreaDescription(filePath, uuidHolder);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + ".ImportAreaDescription() Could not import area description at path: " + filePath);
     }
     else
     {
         byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
         Marshal.Copy(uuidHolder, tempDataBuffer, 0, Common.UUID_LENGTH);
         adfID.SetDataUUID(tempDataBuffer);
     }
     return returnValue;
 }
Пример #12
0
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Saves the metadata associated with a single area description unique ID.
 /// </summary>
 /// <returns>
 /// Returns TANGO_SUCCESS on successful save, or TANGO_ERROR on failure, or if the service needs to be
 /// initialized.
 /// </returns>
 /// <param name="adfUnityHolder">The metadata and associated UUID to save.</param>
 public static int SaveAreaDescriptionMetaData(UUIDUnityHolder adfUnityHolder)
 {
     if (adfUnityHolder == null)
     {
         Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
         return Common.ErrorType.TANGO_ERROR;
     }
     if (string.IsNullOrEmpty(adfUnityHolder.GetStringDataUUID()))
     {
         Debug.Log(CLASS_NAME + ".MetaData cannot be retrived for the area description as UUIDUnityHolder object was empty or null.");
         return Common.ErrorType.TANGO_ERROR;
     }
     if (adfUnityHolder.uuidMetaData.meta_data_pointer == IntPtr.Zero)
     {
         Debug.Log(CLASS_NAME + "metadata pointer is null, cannot save metadata to this ADF!");
         return Common.ErrorType.TANGO_ERROR;
     }
     Debug.Log("UUID being saved is: " + adfUnityHolder.GetStringDataUUID());
     int returnValue = PoseProviderAPI.TangoService_saveAreaDescriptionMetadata(adfUnityHolder.GetStringDataUUID(), adfUnityHolder.uuidMetaData.meta_data_pointer);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + "Could not save metadata to the ADF!");
     }
     return returnValue;
 }
Пример #13
0
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Saves the area description, returning the unique ID associated with the saved map.
 /// 
 /// You can only save an area description while connected to the Tango Service and if you have enabled Area
 /// Learning mode. If you loaded an ADF before connecting, then calling this method appends any new learned
 /// areas to that ADF and returns the same UUID. If you did not load an ADF, this method creates a new ADF and
 /// a new UUID for that ADF.
 /// </summary>
 /// <returns>
 /// Returns TANGO_SUCCESS on success, and TANGO_ERROR if a failure occurred when saving, or if the service
 /// needs to be initialized, or TANGO_INVALID if uuid is NULL, or of incorrect length, or if Area Learning Mode
 /// was not set (see logcat for details).
 /// </returns>
 /// <param name="adfUnityHolder">Upon saving, the TangoUUID to refer to this ADF is returned here.</param>
 public static int SaveAreaDescription(UUIDUnityHolder adfUnityHolder)
 {
     if (adfUnityHolder == null)
     {
         Debug.Log(CLASS_NAME + ".SaveAreaDescription() Could not save area description. UUID Holder object specified is not initialized");
         return Common.ErrorType.TANGO_ERROR;
     }
     IntPtr idData = Marshal.AllocHGlobal(Common.UUID_LENGTH);
     int returnValue = PoseProviderAPI.TangoService_saveAreaDescription(idData);
     if (returnValue != Common.ErrorType.TANGO_SUCCESS)
     {
         Debug.Log(CLASS_NAME + ".SaveAreaDescripton() Could not save area description with ID: " + adfUnityHolder.GetStringDataUUID());
     }
     else
     {
         byte[] tempDataBuffer = new byte[Common.UUID_LENGTH];
         Marshal.Copy(idData, tempDataBuffer, 0, Common.UUID_LENGTH);
         adfUnityHolder.SetDataUUID(tempDataBuffer);
     }
     return returnValue;
 }
Пример #14
0
 /// DEPRECATED: Use the AreaDescription class to work with area descriptions.
 /// <summary>
 /// Check if an area description ID is valid.
 /// </summary>
 /// <returns><c>true</c> if the ID is valid; otherwise, <c>false</c>.</returns>
 /// <param name="toCheck">Area description ID to check.</param>
 public static bool IsUUIDValid(UUIDUnityHolder toCheck)
 {
     return toCheck != null && toCheck.IsObjectValid();
 }
 /// <summary>
 /// Start is called after Awake.Make any initilizations here.
 /// </summary>
 private void Start()
 {
     m_tangoApplication = FindObjectOfType<TangoApplication>();
     m_adfUnityHolder = new UUIDUnityHolder();
     m_keyboardState = KeyboardState.NONE;
 }
Пример #16
0
 /// <summary>
 /// Check if an area description ID is valid.
 /// </summary>
 /// <returns><c>true</c> if the ID is valid; otherwise, <c>false</c>.</returns>
 /// <param name="toCheck">Area description ID to check.</param>
 public static bool IsUUIDValid(UUIDUnityHolder toCheck)
 {
     return(toCheck != null && toCheck.IsObjectValid());
 }