|
|
@ -1,9 +1,11 @@
|
|
|
|
using Common.Const;
|
|
|
|
using Common.Const;
|
|
|
|
|
|
|
|
using Entity.Ammeter;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using HybirdFrameworkCore.Const;
|
|
|
|
using HybirdFrameworkCore.Const;
|
|
|
|
using HybirdFrameworkDriver.ModbusTcpMaster;
|
|
|
|
using HybirdFrameworkDriver.ModbusTcpMaster;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Repository.Ammeter;
|
|
|
|
using Repository.Station;
|
|
|
|
using Repository.Station;
|
|
|
|
using Service.Ammeter.Msg;
|
|
|
|
using Service.Ammeter.Msg;
|
|
|
|
using Service.FireControl.Msg;
|
|
|
|
using Service.FireControl.Msg;
|
|
|
@ -14,6 +16,8 @@ namespace Service.FireControl.Client;
|
|
|
|
public class AmmeterClient : ModbusTcpMaster
|
|
|
|
public class AmmeterClient : ModbusTcpMaster
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(AmmeterClient));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(AmmeterClient));
|
|
|
|
|
|
|
|
public EmeterEnergyRepository EmeterEnergyRepository { get; set; }
|
|
|
|
|
|
|
|
public EmeterEnergyChangeRepository EmeterEnergyChangeRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public AmmeterClient()
|
|
|
|
public AmmeterClient()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -38,6 +42,29 @@ public class AmmeterClient : ModbusTcpMaster
|
|
|
|
{
|
|
|
|
{
|
|
|
|
connectResult = true;
|
|
|
|
connectResult = true;
|
|
|
|
ModbusDecoder.Decode<ACMeters>(readPowerValue, AmmeterMgr.ACMeters, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
ModbusDecoder.Decode<ACMeters>(readPowerValue, AmmeterMgr.ACMeters, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 插入电能数据
|
|
|
|
|
|
|
|
DateTime time = DateTime.Now.AddDays(-7);
|
|
|
|
|
|
|
|
EmeterEnergyRepository.Delete(i => i.UploadTime < time);
|
|
|
|
|
|
|
|
EmeterEnergyChangeRepository.Delete(i => i.UploadTime < time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string id = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
|
|
|
|
|
string code = "";//电表编号
|
|
|
|
|
|
|
|
id = id + "_" + code;
|
|
|
|
|
|
|
|
EmeterEnergyChange emeterEnergyChange = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = id,
|
|
|
|
|
|
|
|
UploadFlag = 0,
|
|
|
|
|
|
|
|
Value = AmmeterMgr.ACMeters.ActiveTotalEnergy.Value,
|
|
|
|
|
|
|
|
Code = code,
|
|
|
|
|
|
|
|
UploadTime = DateTime.Now
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EmeterEnergyChangeRepository.Insert(emeterEnergyChange);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
return connectResult;
|
|
|
|
return connectResult;
|
|
|
|