优化数据通道管理
This commit is contained in:
parent
fd9e3e5af3
commit
0d2bfdc33c
@ -250,7 +250,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
||||
Pn = request.Pn,
|
||||
Fn = request.Fn
|
||||
};
|
||||
var bytes = Build3761SendData.BuildSendCommandBytes(reqParameter);
|
||||
|
||||
var bytes = Build3761SendData.BuildSendCommandBytes(reqParameter,request.DataUnit);
|
||||
return new Telemetry3761PacketResponse() { Seq = reqParameter.Seq.PRSEQ, Data = bytes, MSA = reqParameter.MSA, };
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -706,6 +706,36 @@ namespace JiShe.CollectBus.Protocol.T37612012
|
||||
/// <returns></returns>
|
||||
public static int CalculateFn(string dt1, string dt2) => dt2.HexToDec() * 8 + (8 - dt1.HexTo4BinZero().IndexOf("1"));
|
||||
|
||||
#region 下行
|
||||
/// <summary>
|
||||
/// 生成二类项采集项时间数据单元
|
||||
/// </summary>
|
||||
/// <param name="timeMark"></param>
|
||||
/// <param name="validLength"></param>
|
||||
/// <returns></returns>
|
||||
public virtual List<string> Generate_DataUnit(DataTimeMark timeMark)
|
||||
{
|
||||
List<string> values = new List<string>
|
||||
{
|
||||
SplitDataTime(timeMark.DataTime)//数据时间
|
||||
};
|
||||
if (timeMark.Density > 0)
|
||||
values.Add(timeMark.Density.HexToDecStr().PadLeft(2, '0'));//密度
|
||||
if (timeMark.Point > 0)
|
||||
values.Add(timeMark.Point.HexToDecStr().PadLeft(2, '0'));//数据点数
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
private string SplitDataTime(DateTime dataTime)
|
||||
{
|
||||
//2101060815
|
||||
List<string> values = new List<string>() { $"{dataTime}:YY", $"{dataTime}:MM", $"{dataTime}:dd", $"{dataTime}:HH", $"{dataTime}:mm", };
|
||||
|
||||
values.Reverse();
|
||||
return string.Join("", values);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 上行命令
|
||||
|
||||
@ -113,6 +113,11 @@ namespace JiShe.CollectBus.Protocol.T6452007
|
||||
}
|
||||
}
|
||||
|
||||
if (aFNStr == "0D")//二类数据
|
||||
{
|
||||
dataUnit = Generate_DataUnit(request.DataTimeMark);
|
||||
}
|
||||
|
||||
string afnMethonCode = $"AFN{aFNStr}_Fn_Send";
|
||||
if (base.T3761AFNHandlers != null && base.T3761AFNHandlers.TryGetValue(afnMethonCode
|
||||
, out var handler))
|
||||
|
||||
29
protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs
Normal file
29
protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据时间标记
|
||||
/// </summary>
|
||||
public class DataTimeMark
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据时间
|
||||
/// </summary>
|
||||
public DateTime DataTime { get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// 数据点数
|
||||
/// </summary>
|
||||
public int Point { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 冻结密度(-1、采集项本身无密度位,0、无,1、15分钟,2、30分钟,3、60分钟,245、5分钟,255、1分钟)
|
||||
/// </summary>
|
||||
public int Density { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
namespace JiShe.CollectBus.Protocol.Models
|
||||
using JiShe.CollectBus.Common.BuildSendDatas;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 报文构建参数
|
||||
@ -21,9 +23,9 @@
|
||||
public required string ItemCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务时间戳
|
||||
/// 任务时间
|
||||
/// </summary>
|
||||
public long TimeStamp { get; set; }
|
||||
public DataTimeMark DataTimeMark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器转发协议构建构建参数
|
||||
|
||||
@ -98,6 +98,7 @@ namespace JiShe.CollectBus.DataChannels
|
||||
timer.Restart();
|
||||
|
||||
var startTime = DateTime.Now;
|
||||
string topicName = string.Empty;
|
||||
|
||||
while (taskInfoList != null && taskInfoList.Count < batchSize && (DateTime.Now - startTime) < timeout)
|
||||
{
|
||||
@ -105,6 +106,7 @@ namespace JiShe.CollectBus.DataChannels
|
||||
{
|
||||
if (_telemetryPacketInfoReader.TryRead(out var dataItem))
|
||||
{
|
||||
topicName = dataItem.Item1;
|
||||
taskInfoList.AddRange(dataItem.Item2);
|
||||
}
|
||||
}
|
||||
@ -124,7 +126,7 @@ namespace JiShe.CollectBus.DataChannels
|
||||
deviceIdSelector: data => data.DeviceId,
|
||||
processor: (data, groupIndex) =>
|
||||
{
|
||||
// _ = KafkaProducerIssuedMessageAction(dateItem.Item1, data, groupIndex);
|
||||
//_ = KafkaProducerIssuedMessageAction(dateItem.Item1, data, groupIndex);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -736,6 +736,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
FocusAddress = ammeterInfo.FocusAddress,
|
||||
Pn = ammeterInfo.MeteringCode,
|
||||
ItemCode = tempItem,
|
||||
DataTimeMark = new Protocol.DataTimeMark()
|
||||
{
|
||||
Density = ammeterInfo.TimeDensity,//todo 转换成协议的值
|
||||
Point = 1,
|
||||
DataTime = timestamps,
|
||||
}
|
||||
});
|
||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||
{
|
||||
@ -1521,7 +1527,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
member = page.NextMember;
|
||||
}
|
||||
|
||||
|
||||
//var page = await _redisDataCacheService.GetAllPagedData<T>(
|
||||
// redisCacheMeterInfoHashKeyTemp,
|
||||
// redisCacheMeterInfoZSetScoresIndexKeyTemp,
|
||||
|
||||
@ -245,7 +245,7 @@ namespace JiShe.CollectBus.Common.Extensions
|
||||
/// <param name="dateLong"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static DateTime ParseIntToDate(long dateLong)
|
||||
public static DateTime ParseIntToDate(this long dateLong)
|
||||
{
|
||||
if (dateLong < 10000101 || dateLong > 99991231)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user