Merge remote-tracking branch 'origin/zw' into zw

zw
CZ 4 months ago
commit a1d941deca

@ -0,0 +1,46 @@
using Common.Const;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
using log4net;
using Repository.Station;
using Service.Ammeter.Msg;
using Service.FireControl.Msg;
namespace Service.FireControl.Client;
[Scope]
public class AmmeterClient : ModbusTcpMaster
{
private static readonly ILog Log = LogManager.GetLogger(typeof(AmmeterClient));
public AmmeterClient()
{
ReadAction = BatchRead;
Ip = "";//172.0.50.100
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private bool BatchRead(ModbusTcpMaster master)
{
bool connectResult = false;
Log.Info("Ammeter start read");
#region 电表
//var bytes03 = master.Read("s=2;x=3;1", 3).Content;//0x03
var readPowerValue = master.Read("x=3;39424", 2).Content;
if (readPowerValue != null)
{
connectResult = true;
ModbusDecoder.Decode<ACMeters>(readPowerValue, AmmeterMgr.ACMeters, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
#endregion
return connectResult;
}
}

@ -0,0 +1,45 @@
using Autofac;
using HybirdFrameworkCore.Autofac;
using Service.Ammeter.Msg;
using Service.FireControl.Msg;
using Service.Plc.Client;
namespace Service.FireControl.Client;
public class AmmeterMgr
{
public static ACMeters ACMeters = new ACMeters();
public static AmmeterClient? AmmeterClient { get; set; }
#region MyRegion
public static void Init()
{
if (AmmeterClient == null)
{
AmmeterClient = AppInfo.Container.Resolve<AmmeterClient>();
}
Task.Run(() => AmmeterClient.Connect());
}
/// <summary>
/// 写
/// </summary>
/// <returns></returns>
public static bool ResettingOn()
{
if (AmmeterClient != null)
{
return AmmeterClient.WriteValue(ACMeters.ActiveTotalEnergy);
}
return false;
}
#endregion
}

File diff suppressed because it is too large Load Diff

@ -137,8 +137,11 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
private static ushort _incrementId; private static ushort _incrementId;
private static ushort GetIncrementId() private static int GetIncrementId()
{ {
string s = DateTime.Now.ToString("yyMMddHHmmss");
if (_incrementId < 65535) if (_incrementId < 65535)
{ {
_incrementId += 1; _incrementId += 1;
@ -148,7 +151,8 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
_incrementId = 1; _incrementId = 1;
} }
return _incrementId;
return Int32.Parse(s+_incrementId);
} }
public void InitHandler() public void InitHandler()

Loading…
Cancel
Save