You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

using DotNetty.Transport.Channels;
6 months ago
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.Session;
using Service.Charger.Common;
6 months ago
namespace Service.Charger.Client;
6 months ago
/// <summary>
6 months ago
/// 示例程序
6 months ago
/// </summary>
[Scope("SingleInstance")]
public static class ClientMgr
6 months ago
{
private static readonly Dictionary<int, ChargerClient> Dictionary = new();
public static ChargerClient? GetBySn(int sn)
6 months ago
{
Dictionary.TryGetValue(sn, out var o);
return o;
}
public static bool TryGetClient(IChannel channel, out string sn, out ChargerClient? client)
{
string? snt = ChannelUtils.GetAttr(channel, ChargerConst.ChargerSn);
if (!string.IsNullOrWhiteSpace(snt))
{
var chargerClient = GetBySn(int.Parse(snt));
if (chargerClient != null)
{
sn = snt;
client = chargerClient;
return true;
}
}
6 months ago
sn = string.Empty;
client = null;
return false;
}
6 months ago
public static void AddBySn(int sn, ChargerClient client)
{
Dictionary[sn] = client;
}
//TODO 连接、鉴权,开始充电,结束充电,设置尖峰平谷,读取尖峰平谷,发送功率调节指令,发送辅助源控制指令,下发掉线停止充电,
public static void InitClient()
{
6 months ago
}
}