完善3761下行透明转发处理逻辑
This commit is contained in:
parent
be3cd5d3e7
commit
e02a0953e9
@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using JiShe.CollectBus.Common.BuildSendDatas;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Models;
|
||||
@ -259,6 +260,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
||||
#region AFN10H 数据转发
|
||||
public static Telemetry3761PacketResponse AFN10_Fn_Send(Telemetry3761PacketRequest request)
|
||||
{
|
||||
|
||||
var baudRateValue = Build3761SendData.GetBaudreate($"{request.SubRequest.Baudrate}");
|
||||
|
||||
var dataUnit = Build3761SendData.BuildTransparentForwardingSendDataUnit(request.SubRequest.MeteringPort, baudRateValue, request.DataUnit);
|
||||
dataUnit.AddRange(Build3761SendData.GetPW());
|
||||
|
||||
var reqParameter = new ReqParameter2()
|
||||
{
|
||||
AFN = AFN.数据转发,
|
||||
@ -275,7 +282,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
||||
Pn = request.Pn,
|
||||
Fn = request.Fn
|
||||
};
|
||||
var bytes = Build3761SendData.BuildSendCommandBytes(reqParameter, request.DataUnit);
|
||||
var bytes = Build3761SendData.BuildSendCommandBytes(reqParameter, dataUnit);
|
||||
return new Telemetry3761PacketResponse() { Seq = reqParameter.Seq.PRSEQ, Data = bytes, MSA = reqParameter.MSA, };
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
||||
using JiShe.CollectBus.Protocol.Models;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建3761报文参数
|
||||
@ -20,8 +22,13 @@
|
||||
/// </summary>
|
||||
public int Pn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子协议请求
|
||||
/// </summary>
|
||||
public SubProtocolBuildRequest SubRequest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 透明转发单元
|
||||
/// 透明转发数据单元
|
||||
/// </summary>
|
||||
public List<string> DataUnit { get; set; }
|
||||
}
|
||||
|
||||
@ -1,23 +1,12 @@
|
||||
namespace JiShe.CollectBus.Protocol.T6452007.SendData
|
||||
using JiShe.CollectBus.Protocol.Models;
|
||||
|
||||
namespace JiShe.CollectBus.Protocol.T6452007.SendData
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建645报文参数
|
||||
/// </summary>
|
||||
public class Telemetry6452007PacketRequest
|
||||
public class Telemetry6452007PacketRequest: SubProtocolBuildRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 表地址
|
||||
/// </summary>
|
||||
public required string MeterAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public required string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作码
|
||||
/// </summary>
|
||||
public required string ItemCode { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +129,7 @@ namespace JiShe.CollectBus.Protocol.T6452007
|
||||
FocusAddress = request.FocusAddress,
|
||||
Fn = fn,
|
||||
Pn = request.Pn,
|
||||
SubRequest = request.SubProtocolRequest,
|
||||
DataUnit = dataUnit,
|
||||
});
|
||||
}
|
||||
|
||||
@ -10,6 +10,16 @@
|
||||
/// </summary>
|
||||
public required string MeterAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 波特率 default(2400)
|
||||
/// </summary>
|
||||
public int Baudrate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计量端口
|
||||
/// </summary>
|
||||
public int MeteringPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
|
||||
@ -125,7 +125,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
BrandType = "DTS1980",
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
ProjectID = 1,
|
||||
MeteringPort = 2,
|
||||
MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
Password = "000000",
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
BrandType = "DTS1980",
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
ProjectID = 1,
|
||||
MeteringPort = 2,
|
||||
MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
Password = "000000",
|
||||
});
|
||||
|
||||
@ -279,37 +279,49 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
string currentTimeStr = $"{currentTime:HH:mm}";
|
||||
|
||||
try
|
||||
{
|
||||
{
|
||||
#if DEBUG
|
||||
var settingInfos = new List<AmmeterAutoValveControlSetting>();
|
||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
//电表自动阀控缓存
|
||||
string redisCacheDeviceSettingInfoHashKey = $"redisCacheDeviceSettingInfoHashKey_{SystemType}_{ServerTagName}";
|
||||
|
||||
var settingInfos = FreeRedisProvider.Instance.Get< List<AmmeterAutoValveControlSetting>> (redisCacheDeviceSettingInfoHashKey);
|
||||
if (settingInfos == null || settingInfos.Count <= 0)
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
AmmerterAddress = "442405000040",
|
||||
FocusAddress = "442400040",
|
||||
FocusId = 95780,
|
||||
ProjectID = 1,
|
||||
TripType = "on",
|
||||
TripTime = $"{DateTime.Now:HH:mm}",
|
||||
MeterId = 127035,
|
||||
LoopType = "EachDay",
|
||||
EachDayWithout = "周六,周日",
|
||||
TimeDensity = 15,
|
||||
});
|
||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
AmmerterAddress = "442405000039",
|
||||
FocusAddress = "442400039",
|
||||
FocusId = 69280,
|
||||
ProjectID = 1,
|
||||
TripType = "on",
|
||||
TripTime = $"{DateTime.Now:HH:mm}",
|
||||
MeterId = 95594,
|
||||
LoopType = "EachDay",
|
||||
EachDayWithout = "周六,周日",
|
||||
TimeDensity = 15,
|
||||
});
|
||||
settingInfos = new List<AmmeterAutoValveControlSetting>();
|
||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
AmmerterAddress = "442405000040",
|
||||
FocusAddress = "442400040",
|
||||
FocusId = 95780,
|
||||
ProjectID = 1,
|
||||
TripType = "on",
|
||||
TripTime = $"{DateTime.Now:HH:mm}",
|
||||
MeterId = 127035,
|
||||
LoopType = "EachDay",
|
||||
EachDayWithout = "周六,周日",
|
||||
TimeDensity = 15,
|
||||
});
|
||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
AmmerterAddress = "442405000039",
|
||||
FocusAddress = "442400039",
|
||||
FocusId = 69280,
|
||||
ProjectID = 1,
|
||||
TripType = "on",
|
||||
TripTime = $"{DateTime.Now:HH:mm}",
|
||||
MeterId = 95594,
|
||||
LoopType = "EachDay",
|
||||
EachDayWithout = "周六,周日",
|
||||
TimeDensity = 15,
|
||||
});
|
||||
|
||||
|
||||
FreeRedisProvider.Instance.Set(redisCacheDeviceSettingInfoHashKey, settingInfos);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
//获取电表阀控配置
|
||||
var settingInfos = await GetAmmeterAutoValveControlSetting(currentTimeStr);
|
||||
@ -375,7 +387,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
bool tripStateResult = false;
|
||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
||||
string subItemCode = string.Empty;
|
||||
if (settingInfo.TripType.Equals("on"))
|
||||
if (settingInfo.TripType.Equals("on"))//当前电表断闸,需要合闸
|
||||
{
|
||||
ammeterInfo.TripState = 0;
|
||||
tripStateResult = true;
|
||||
@ -385,7 +397,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
subItemCode = T6452007PacketItemCodeConst.C1C011B;
|
||||
}
|
||||
}
|
||||
else if (settingInfo.TripType.Equals("off"))
|
||||
else if (settingInfo.TripType.Equals("off"))//当前电表合闸,需要断闸
|
||||
{
|
||||
ammeterInfo.TripState = 1;
|
||||
tripStateResult = false;
|
||||
@ -416,6 +428,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
MeterAddress = ammeterInfo.MeterAddress,
|
||||
Password = ammeterInfo.Password,
|
||||
ItemCode = subItemCode,
|
||||
Baudrate = ammeterInfo.Baudrate,
|
||||
MeteringPort = ammeterInfo.MeteringPort
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1362,7 +1362,7 @@ namespace JiShe.CollectBus.Common.BuildSendDatas
|
||||
/// <param name="waitContentTimeout">等待报文超时时间/s</param>
|
||||
/// <param name="waitByteTimeout">等待字节超时时间/ms</param>
|
||||
/// <returns></returns>
|
||||
private static List<string> BuildTransparentForwardingSendDataUnit(int port, int baudRate, List<string> datas, StopBit stopBit = StopBit.Stop1, Parity parity = Parity.Even, DataBit dataBit = DataBit.D8,
|
||||
public static List<string> BuildTransparentForwardingSendDataUnit(int port, int baudRate, List<string> datas, StopBit stopBit = StopBit.Stop1, Parity parity = Parity.Even, DataBit dataBit = DataBit.D8,
|
||||
int waitContentTimeout = 100, int waitByteTimeout = 100)
|
||||
{
|
||||
var dataUnit = new List<string>();
|
||||
@ -1591,7 +1591,7 @@ namespace JiShe.CollectBus.Common.BuildSendDatas
|
||||
|
||||
|
||||
//AUX=消息认证码字段(PW,16个字节)
|
||||
private static List<string> GetPW()
|
||||
public static List<string> GetPW()
|
||||
{
|
||||
var str = "00";
|
||||
var pWList = Enumerable.Repeat(str, pWLen).ToList();
|
||||
|
||||
24
shared/JiShe.CollectBus.Common/Consts/MeteringPortConst.cs
Normal file
24
shared/JiShe.CollectBus.Common/Consts/MeteringPortConst.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// 计量端口常量
|
||||
/// </summary>
|
||||
public class MeteringPortConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 计量端口1
|
||||
/// </summary>
|
||||
public const int MeteringPortOne = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 计量端口2
|
||||
/// </summary>
|
||||
public const int MeteringPortTwo = 2;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user