/// <summary> /// Set this config as the current runtime config. /// </summary> internal void SetRuntimeConfig() { bool wasSuccess = TangoConfigAPI.TangoService_setRuntimeConfig(m_configHandle) == Common.ErrorType.TANGO_SUCCESS; if (!wasSuccess) { Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, "SetRuntimeConfig")); } }
public void SetRuntimeConfig() { bool wasSuccess = TangoConfigAPI.TangoService_setRuntimeConfig(m_configHandle) == Common.ErrorType.TANGO_SUCCESS; if (!wasSuccess) { Debug.Log(string.Format("{0}.SetRuntimeConfig() Unable to set runtime config.", CLASS_NAME)); } }
/// <summary> /// Gets a string of key-value pairs of all the configuration values of TangoService. /// /// The string is separated into lines such that each line is one key-value pair, with format "key=value\n". /// Note that many of these config values are read-only, unless otherwise documented. /// </summary> /// <returns>String representation of the cached configuration.</returns> internal string GetSettings() { if (m_configHandle != IntPtr.Zero) { return(TangoConfigAPI.TangoConfig_toString(m_configHandle)); } else { return(NO_CONFIG_FOUND); } }
/// <summary> /// Gets a string representing the current settings /// of the Tango configuration. /// </summary> /// <returns> String representing the current settings. /// Null if no configuration is found.</returns> public static string GetSettings() { if (m_tangoConfig != IntPtr.Zero) { return(TangoConfigAPI.TangoConfig_toString(m_tangoConfig)); } else { return(NO_CONFIG_FOUND); } }
/// <summary> /// Deallocate a Tango configuration object. /// </summary> public static void Free() { if (m_tangoConfig != IntPtr.Zero) { TangoConfigAPI.TangoConfig_free(m_tangoConfig); } else { Debug.Log(CLASS_NAME + ".Free() No allocated Tango Config found!"); } }
/// <summary> /// Deallocate a Tango configuration object. /// </summary> public static void Free() { if (m_tangoConfig != IntPtr.Zero) { TangoConfigAPI.TangoConfig_free(m_tangoConfig); } else { DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_CRITICAL, CLASS_NAME + ".Free() No allocated Tango Config found!"); } }
/// <summary> /// Gets the value of an int64 key/value pair. /// </summary> /// <returns><c>true</c>, if int64 was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetInt64(string key, ref Int64 value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { wasSuccess = TangoConfigAPI.TangoConfig_getInt64(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS; } if (!wasSuccess) { Debug.Log(string.Format(m_ErrorLogFormat, "GetInt64", key, value)); } return(wasSuccess); }
/// <summary> /// Releases all resource used by the <see cref="Tango.TangoConfig"/> object. /// </summary> /// <remarks>Call <see cref="Dispose"/> when you are finished using the <see cref="Tango.TangoConfig"/>. The /// <see cref="Dispose"/> method leaves the <see cref="Tango.TangoConfig"/> in an unusable state. After calling /// <see cref="Dispose"/>, you must release all references to the <see cref="Tango.TangoConfig"/> so the garbage /// collector can reclaim the memory that the <see cref="Tango.TangoConfig"/> was occupying.</remarks> public void Dispose() { if (m_configHandle != IntPtr.Zero) { TangoConfigAPI.TangoConfig_free(m_configHandle); m_configHandle = IntPtr.Zero; } else { Debug.Log(CLASS_NAME + ".Free() No allocated Tango Config found!"); } GC.SuppressFinalize(this); }
/// <summary> /// Gets the value of a double key/value pair. /// </summary> /// <returns><c>true</c>, if double was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetDouble(string key, ref double value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { wasSuccess = TangoConfigAPI.TangoConfig_getDouble(m_tangoConfig, key, ref value) == 0; } if (!wasSuccess) { Debug.Log(string.Format(m_ErrorLogFormat, "GetDouble", key, value)); } return(wasSuccess); }
/// <summary> /// Gets the value of a double key/value pair. /// </summary> /// <returns><c>true</c>, if double was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetDouble(string key, ref double value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { wasSuccess = TangoConfigAPI.TangoConfig_getDouble(m_tangoConfig, key, ref value) == 0; } if (!wasSuccess) { DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR, string.Format(m_ErrorLogFormat, "GetDouble", key, value)); } return(wasSuccess); }
/// <summary> /// Gets the value of an int32 kay/value pair. /// </summary> /// <returns><c>true</c>, if int32 was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetInt32(string key, ref Int32 value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { wasSuccess = TangoConfigAPI.TangoConfig_getInt32(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS; } if (!wasSuccess) { DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR, string.Format(m_ErrorLogFormat, "GetInt32", key, value)); } return(wasSuccess); }
/// <summary> /// Gets the value of a bool key/value pair. /// </summary> /// <returns><c>true</c>, if bool was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetBool(string key, ref bool value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { wasSuccess = TangoConfigAPI.TangoConfig_getBool(m_tangoConfig, key, ref value) == Common.ErrorType.TANGO_SUCCESS; } if (!wasSuccess) { #if UNITY_ANDROID && !UNITY_EDITOR Debug.Log(string.Format(m_ErrorLogFormat, "GetBool", key, false)); #endif } return(wasSuccess); }
/// <summary> /// Gets the value of a string key/value pair. /// </summary> /// <returns><c>true</c>, if string was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetString(string key, ref string value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { UInt32 stringLength = 512; StringBuilder tempString = new StringBuilder(512); wasSuccess = TangoConfigAPI.TangoConfig_getString(m_tangoConfig, key, tempString, stringLength) == Common.ErrorType.TANGO_SUCCESS; if (wasSuccess) { value = tempString.ToString(); } else { Debug.Log(string.Format(m_ErrorLogFormat, "GetString", key, value)); } } return(wasSuccess); }
/// <summary> /// Get a string configuration parameter. /// </summary> /// <returns><c>true</c>, if the value was retrieved, <c>false</c> otherwise.</returns> /// <param name="key">The string key value of the configuration parameter to get.</param> /// <param name="value">On successful return, the value of the configuration key.</param> internal bool GetString(string key, ref string value) { // Can't use _ConfigHelperGet because the API takes a size parameter. string tangoMethodName = "GetString"; if (m_configHandle == IntPtr.Zero) { Debug.Log(string.Format(m_ConfigErrorFormat, CLASS_NAME, tangoMethodName)); return(false); } bool wasSuccess = false; StringBuilder stringBuilder = new StringBuilder(512); wasSuccess = TangoConfigAPI.TangoConfig_getString(m_configHandle, key, stringBuilder, (uint)stringBuilder.Capacity) == Common.ErrorType.TANGO_SUCCESS; value = stringBuilder.ToString(); if (!wasSuccess) { Debug.Log(string.Format(m_ErrorLogFormat, CLASS_NAME, tangoMethodName, key)); } return(wasSuccess); }
/// <summary> /// Gets the value of a string key/value pair. /// </summary> /// <returns><c>true</c>, if string was gotten, <c>false</c> otherwise.</returns> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static bool GetString(string key, ref string value) { bool wasSuccess = false; if (m_tangoConfig != IntPtr.Zero) { UInt32 stringLength = 512; // char[] tempString = new char[512]; StringBuilder tempString = new StringBuilder(512); wasSuccess = TangoConfigAPI.TangoConfig_getString(m_tangoConfig, key, tempString, stringLength) == Common.ErrorType.TANGO_SUCCESS; if (wasSuccess) { value = tempString.ToString(); } else { DebugLogger.GetInstance.WriteToLog(DebugLogger.EDebugLevel.DEBUG_ERROR, string.Format(m_ErrorLogFormat, "GetString", key, value)); } } return(wasSuccess); }
/// <summary> /// Fills out a given Tango configuration with the currently set configuration settings. /// </summary> public static void InitConfig(TangoEnums.TangoConfigType configType) { m_tangoConfig = TangoConfigAPI.TangoService_getConfig(configType); // TODO : error check this! }
/// <summary> /// Create a new TangoConfig. /// /// A TangoConfig is passed to TangoService_connect() which starts the service running with /// the parameters set at that time in that TangoConfig. This function can be used to find the current /// configuration of the service (i.e. what would be run if no config is specified on TangoService_connect()), /// or to create one of a few "template" TangoConfig objects. /// /// The class is needed only at the time of TangoService_connect() where it is used to configure the service /// and can safely be disposed after it has been used in TangoService_connect(). /// </summary> /// <param name="configType">The requested configuration type.</param> public TangoConfig(TangoEnums.TangoConfigType configType) { m_configHandle = TangoConfigAPI.TangoService_getConfig(configType); }