From 0d2bfdc33c76991e48da63ce1158d162395567c0 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Wed, 30 Apr 2025 17:11:09 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E9=80=9A?=
=?UTF-8?q?=E9=81=93=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SendData/Telemetry3761PacketBuilder.cs | 3 +-
.../T37612012ProtocolPlugin.cs | 30 +++++++++++++++++++
.../T6452007ProtocolPlugin.cs | 5 ++++
.../Models/DataTimeMark.cs | 29 ++++++++++++++++++
.../Models/ProtocolBuildRequest.cs | 8 +++--
.../DataChannels/DataChannelManageService.cs | 4 ++-
.../BasicScheduledMeterReadingService.cs | 7 ++++-
.../Extensions/DateTimeExtensions.cs | 2 +-
8 files changed, 81 insertions(+), 7 deletions(-)
create mode 100644 protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs
diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/SendData/Telemetry3761PacketBuilder.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/SendData/Telemetry3761PacketBuilder.cs
index ab43cc8..f8bfa78 100644
--- a/protocols/JiShe.CollectBus.Protocol.T37612012/SendData/Telemetry3761PacketBuilder.cs
+++ b/protocols/JiShe.CollectBus.Protocol.T37612012/SendData/Telemetry3761PacketBuilder.cs
@@ -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
diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/T37612012ProtocolPlugin.cs b/protocols/JiShe.CollectBus.Protocol.T37612012/T37612012ProtocolPlugin.cs
index b7b3446..a469147 100644
--- a/protocols/JiShe.CollectBus.Protocol.T37612012/T37612012ProtocolPlugin.cs
+++ b/protocols/JiShe.CollectBus.Protocol.T37612012/T37612012ProtocolPlugin.cs
@@ -706,6 +706,36 @@ namespace JiShe.CollectBus.Protocol.T37612012
///
public static int CalculateFn(string dt1, string dt2) => dt2.HexToDec() * 8 + (8 - dt1.HexTo4BinZero().IndexOf("1"));
+ #region 下行
+ ///
+ /// 生成二类项采集项时间数据单元
+ ///
+ ///
+ ///
+ ///
+ public virtual List Generate_DataUnit(DataTimeMark timeMark)
+ {
+ List values = new List
+ {
+ 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 values = new List() { $"{dataTime}:YY", $"{dataTime}:MM", $"{dataTime}:dd", $"{dataTime}:HH", $"{dataTime}:mm", };
+
+ values.Reverse();
+ return string.Join("", values);
+ }
+ #endregion
#region 上行命令
diff --git a/protocols/JiShe.CollectBus.Protocol.T6452007/T6452007ProtocolPlugin.cs b/protocols/JiShe.CollectBus.Protocol.T6452007/T6452007ProtocolPlugin.cs
index 4dc789e..a4f820b 100644
--- a/protocols/JiShe.CollectBus.Protocol.T6452007/T6452007ProtocolPlugin.cs
+++ b/protocols/JiShe.CollectBus.Protocol.T6452007/T6452007ProtocolPlugin.cs
@@ -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))
diff --git a/protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs b/protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs
new file mode 100644
index 0000000..2efbaad
--- /dev/null
+++ b/protocols/JiShe.CollectBus.Protocol/Models/DataTimeMark.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JiShe.CollectBus.Protocol
+{
+ ///
+ /// 数据时间标记
+ ///
+ public class DataTimeMark
+ {
+ ///
+ /// 数据时间
+ ///
+ public DateTime DataTime { get; set;}
+
+ ///
+ /// 数据点数
+ ///
+ public int Point { get; set; }
+
+ ///
+ /// 冻结密度(-1、采集项本身无密度位,0、无,1、15分钟,2、30分钟,3、60分钟,245、5分钟,255、1分钟)
+ ///
+ public int Density { get; set; }
+ }
+}
diff --git a/protocols/JiShe.CollectBus.Protocol/Models/ProtocolBuildRequest.cs b/protocols/JiShe.CollectBus.Protocol/Models/ProtocolBuildRequest.cs
index 1e0136a..e287547 100644
--- a/protocols/JiShe.CollectBus.Protocol/Models/ProtocolBuildRequest.cs
+++ b/protocols/JiShe.CollectBus.Protocol/Models/ProtocolBuildRequest.cs
@@ -1,4 +1,6 @@
-namespace JiShe.CollectBus.Protocol.Models
+using JiShe.CollectBus.Common.BuildSendDatas;
+
+namespace JiShe.CollectBus.Protocol.Models
{
///
/// 报文构建参数
@@ -21,9 +23,9 @@
public required string ItemCode { get; set; }
///
- /// 任务时间戳
+ /// 任务时间
///
- public long TimeStamp { get; set; }
+ public DataTimeMark DataTimeMark { get; set; }
///
/// 集中器转发协议构建构建参数
diff --git a/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs b/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs
index f0f7fbe..757af18 100644
--- a/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs
+++ b/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs
@@ -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);
}
);
diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
index 9740c2e..e707f8a 100644
--- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
@@ -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(
// redisCacheMeterInfoHashKeyTemp,
// redisCacheMeterInfoZSetScoresIndexKeyTemp,
diff --git a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs b/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs
index 6936ad3..d7e12e3 100644
--- a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs
+++ b/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs
@@ -245,7 +245,7 @@ namespace JiShe.CollectBus.Common.Extensions
///
///
///
- public static DateTime ParseIntToDate(long dateLong)
+ public static DateTime ParseIntToDate(this long dateLong)
{
if (dateLong < 10000101 || dateLong > 99991231)
{