38 lines
1.0 KiB
C#
Raw Normal View History

2025-04-02 14:06:40 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiShe.CollectBus.IoTDBProvider
{
/// <summary>
/// 设备路径构建器
/// </summary>
public static class DevicePathBuilder
{
/// <summary>
/// 构建存储组路径
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static string BuildStorageGroupPath<T>() where T : IoTEntity
{
var type = typeof(T);
return $"root.{type.GetProperty("SystemName")?.Name}.{type.GetProperty("ProjectCode")?.Name}";
}
/// <summary>
/// 构建设备路径
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity"></param>
/// <returns></returns>
public static string BuildDevicePath<T>(T entity) where T : IoTEntity
{
return $"root.{entity.SystemName}.{entity.ProjectCode}.{entity.DeviceId}";
}
}
}