完善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.BuildSendDatas;
|
||||||
using JiShe.CollectBus.Common.Enums;
|
using JiShe.CollectBus.Common.Enums;
|
||||||
using JiShe.CollectBus.Common.Models;
|
using JiShe.CollectBus.Common.Models;
|
||||||
@ -259,6 +260,12 @@ namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
|||||||
#region AFN10H 数据转发
|
#region AFN10H 数据转发
|
||||||
public static Telemetry3761PacketResponse AFN10_Fn_Send(Telemetry3761PacketRequest request)
|
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()
|
var reqParameter = new ReqParameter2()
|
||||||
{
|
{
|
||||||
AFN = AFN.数据转发,
|
AFN = AFN.数据转发,
|
||||||
@ -275,7 +282,7 @@ namespace JiShe.CollectBus.Protocol.T37612012.SendData
|
|||||||
Pn = request.Pn,
|
Pn = request.Pn,
|
||||||
Fn = request.Fn
|
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, };
|
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>
|
/// <summary>
|
||||||
/// 构建3761报文参数
|
/// 构建3761报文参数
|
||||||
@ -21,7 +23,12 @@
|
|||||||
public int Pn { get; set; }
|
public int Pn { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透明转发单元
|
/// 子协议请求
|
||||||
|
/// </summary>
|
||||||
|
public SubProtocolBuildRequest SubRequest { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 透明转发数据单元
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DataUnit { get; set; }
|
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>
|
/// <summary>
|
||||||
/// 构建645报文参数
|
/// 构建645报文参数
|
||||||
/// </summary>
|
/// </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,
|
FocusAddress = request.FocusAddress,
|
||||||
Fn = fn,
|
Fn = fn,
|
||||||
Pn = request.Pn,
|
Pn = request.Pn,
|
||||||
|
SubRequest = request.SubProtocolRequest,
|
||||||
DataUnit = dataUnit,
|
DataUnit = dataUnit,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,16 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public required string MeterAddress { get; set; }
|
public required string MeterAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 波特率 default(2400)
|
||||||
|
/// </summary>
|
||||||
|
public int Baudrate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计量端口
|
||||||
|
/// </summary>
|
||||||
|
public int MeteringPort { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 密码
|
/// 密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -125,7 +125,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
BrandType = "DTS1980",
|
BrandType = "DTS1980",
|
||||||
MeterType = MeterTypeEnum.Ammeter,
|
MeterType = MeterTypeEnum.Ammeter,
|
||||||
ProjectID = 1,
|
ProjectID = 1,
|
||||||
MeteringPort = 2,
|
MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||||
Password = "000000",
|
Password = "000000",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
BrandType = "DTS1980",
|
BrandType = "DTS1980",
|
||||||
MeterType = MeterTypeEnum.Ammeter,
|
MeterType = MeterTypeEnum.Ammeter,
|
||||||
ProjectID = 1,
|
ProjectID = 1,
|
||||||
MeteringPort = 2,
|
MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||||
Password = "000000",
|
Password = "000000",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -281,7 +281,13 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var settingInfos = new List<AmmeterAutoValveControlSetting>();
|
//电表自动阀控缓存
|
||||||
|
string redisCacheDeviceSettingInfoHashKey = $"redisCacheDeviceSettingInfoHashKey_{SystemType}_{ServerTagName}";
|
||||||
|
|
||||||
|
var settingInfos = FreeRedisProvider.Instance.Get< List<AmmeterAutoValveControlSetting>> (redisCacheDeviceSettingInfoHashKey);
|
||||||
|
if (settingInfos == null || settingInfos.Count <= 0)
|
||||||
|
{
|
||||||
|
settingInfos = new List<AmmeterAutoValveControlSetting>();
|
||||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||||
{
|
{
|
||||||
MeterType = MeterTypeEnum.Ammeter,
|
MeterType = MeterTypeEnum.Ammeter,
|
||||||
@ -310,6 +316,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
EachDayWithout = "周六,周日",
|
EachDayWithout = "周六,周日",
|
||||||
TimeDensity = 15,
|
TimeDensity = 15,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
FreeRedisProvider.Instance.Set(redisCacheDeviceSettingInfoHashKey, settingInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//获取电表阀控配置
|
//获取电表阀控配置
|
||||||
var settingInfos = await GetAmmeterAutoValveControlSetting(currentTimeStr);
|
var settingInfos = await GetAmmeterAutoValveControlSetting(currentTimeStr);
|
||||||
@ -375,7 +387,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
bool tripStateResult = false;
|
bool tripStateResult = false;
|
||||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
||||||
string subItemCode = string.Empty;
|
string subItemCode = string.Empty;
|
||||||
if (settingInfo.TripType.Equals("on"))
|
if (settingInfo.TripType.Equals("on"))//当前电表断闸,需要合闸
|
||||||
{
|
{
|
||||||
ammeterInfo.TripState = 0;
|
ammeterInfo.TripState = 0;
|
||||||
tripStateResult = true;
|
tripStateResult = true;
|
||||||
@ -385,7 +397,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
subItemCode = T6452007PacketItemCodeConst.C1C011B;
|
subItemCode = T6452007PacketItemCodeConst.C1C011B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (settingInfo.TripType.Equals("off"))
|
else if (settingInfo.TripType.Equals("off"))//当前电表合闸,需要断闸
|
||||||
{
|
{
|
||||||
ammeterInfo.TripState = 1;
|
ammeterInfo.TripState = 1;
|
||||||
tripStateResult = false;
|
tripStateResult = false;
|
||||||
@ -416,6 +428,8 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
MeterAddress = ammeterInfo.MeterAddress,
|
MeterAddress = ammeterInfo.MeterAddress,
|
||||||
Password = ammeterInfo.Password,
|
Password = ammeterInfo.Password,
|
||||||
ItemCode = subItemCode,
|
ItemCode = subItemCode,
|
||||||
|
Baudrate = ammeterInfo.Baudrate,
|
||||||
|
MeteringPort = ammeterInfo.MeteringPort
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1362,7 +1362,7 @@ namespace JiShe.CollectBus.Common.BuildSendDatas
|
|||||||
/// <param name="waitContentTimeout">等待报文超时时间/s</param>
|
/// <param name="waitContentTimeout">等待报文超时时间/s</param>
|
||||||
/// <param name="waitByteTimeout">等待字节超时时间/ms</param>
|
/// <param name="waitByteTimeout">等待字节超时时间/ms</param>
|
||||||
/// <returns></returns>
|
/// <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)
|
int waitContentTimeout = 100, int waitByteTimeout = 100)
|
||||||
{
|
{
|
||||||
var dataUnit = new List<string>();
|
var dataUnit = new List<string>();
|
||||||
@ -1591,7 +1591,7 @@ namespace JiShe.CollectBus.Common.BuildSendDatas
|
|||||||
|
|
||||||
|
|
||||||
//AUX=消息认证码字段(PW,16个字节)
|
//AUX=消息认证码字段(PW,16个字节)
|
||||||
private static List<string> GetPW()
|
public static List<string> GetPW()
|
||||||
{
|
{
|
||||||
var str = "00";
|
var str = "00";
|
||||||
var pWList = Enumerable.Repeat(str, pWLen).ToList();
|
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