Skip to content

Commit

Permalink
comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wilyle committed Nov 21, 2023
1 parent 677692c commit e70fe0c
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions cloud_connectors/azure/mqtt_connector/azure_function/src/run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,61 @@ namespace Microsoft.ESDV.CloudConnector.Azure {
/// </summary>
public class DigitalTwinsInstance
{
/// <summary>
/// The Azure Digital Twins model ID
/// </summary>
[JsonPropertyName("model_id")]
public string ModelId { get; set; }

/// <summary>
/// The Azure Digital Twins instance ID
/// </summary>
[JsonPropertyName("instance_id")]
public string InstanceId { get; set; }

/// <summary>
/// The Azure Digital Twins instance property path
/// </summary>
[JsonPropertyName("instance_property_path")]
public string InstancePropertyPath { get; set; }

/// <summary>
/// The data to synchronize
/// </summary>
[JsonPropertyName("data")]
public string Data { get; set; }
}

/// <summary>
/// Azure function for use with the MQTT connector.
/// Reads data from an event grid and forwards it to Azure Digital Twins.
/// </summary>
public class MQTTConnectorAzureFunction
{
/// <summary>
/// The logger for this function
/// </summary>
private readonly ILogger _logger;

/// <summary>
/// The environment variable name for the keyvault settings
/// </summary>
private const string KEYVAULT_SETTINGS = "KEYVAULT_SETTINGS";

// Maps a string data type name to its concrete data type.
/// <summary>
/// Maps a string data type name to its concrete data type.
/// </summary>
private static readonly Dictionary<string, Type> dataTypeNameToConverterMap = new()
{
{ "int", typeof(int) },
{ "double", typeof(double) },
{ "boolean", typeof(bool) }
};

/// <summary>
/// Create a new MQTTConnectorAzureFunction
/// </summary>
/// <param name="logger">The logger to use</param>
public MQTTConnectorAzureFunction(ILogger<MQTTConnectorAzureFunction> logger)
{
_logger = logger;
Expand All @@ -67,7 +95,7 @@ public static bool DoesPathStartsWithSlash(string path)
/// <summary>
/// Gets the data type from a data type name.
/// </summary>
/// <param name="dataTypeName">the name of the data type.
/// <param name="dataTypeName">the name of the data type.</param>
/// <exception cref="NotSupportedException">Thrown if the data type is not supported.</exception>
/// <returns>Returns a task for updating a digital twin instance.</returns>
public static Type GetDataTypeFromString(string dataTypeName)
Expand All @@ -85,7 +113,7 @@ public static Type GetDataTypeFromString(string dataTypeName)
/// </summary>
/// <param name="client">the Azure Digital Twins client.</param>
/// <param name="instance">the digital twin instance to update.</param>
/// <param name="dataTypeName">the name of the data type.
/// <param name="dataTypeName">the name of the data type. Defaults to "double".</param>
/// <returns>Returns a task for updating a digital twin instance.</returns>
public static async Task UpdateDigitalTwinAsync(DigitalTwinsClient client, DigitalTwinsInstance instance, string dataTypeName = "double")
{
Expand Down

0 comments on commit e70fe0c

Please sign in to comment.