plc重连配置

master
wangyueyang 2 months ago
parent 1275c38d31
commit 61277eaf7d

@ -19,7 +19,7 @@ public class FireClient: ModbusTcpMaster
WordSeq= EndingConst.WordSeq.CD;
}
private void BatchRead(ModbusTcpMaster master)
private bool BatchRead(ModbusTcpMaster master)
{
bool resul = Connected;
var bytes01 = master.Read("x=3;1", 80).Content;
@ -40,5 +40,7 @@ public class FireClient: ModbusTcpMaster
ModbusDecoder.Decode<FaultMsg>(bytes02, FireMgr.FaultMsg, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
}
return true;
}
}

@ -14,7 +14,7 @@ public class PadarMgr
public static void InitClient()
{
//TODO::查询 服务器 连接
Task.Run(() => { ConnClient(); });
Task.Run(() => { ConnClient(); });
}
private static void ConnClient()
@ -22,7 +22,7 @@ public class PadarMgr
PadarClient client = AppInfo.Container.Resolve<PadarClient>();
client.AutoReconnect = true;
//client.InitBootstrap("192.168.3.55", int.Parse("2048"));
client.InitBootstrap("127.0.0.1", int.Parse("2048"));
client.InitBootstrap("127.0.0.1", int.Parse("2048"), 10,0, 0);
Task.Run(() =>
{
client.Connect();

@ -28,7 +28,6 @@ public static class ClientMgr
private static void ConnClient()
{
int readTimeout = 5, writeTimeout=5, allTimeout=5;
EquipNetInfo netInfo = new EquipNetInfo()
{
//NetAddr = "192.168.3.246",
@ -41,6 +40,7 @@ public static class ClientMgr
Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
PlcClient = AppInfo.Container.Resolve<PlcClient>();
Log.Info($"plc client Id={PlcClient.GetHashCode()}");
PlcClient.AutoReconnect = true;
PlcClient.Sn = PlcConst.ChargeEqpCode;
@ -51,7 +51,7 @@ public static class ClientMgr
// client.SendAuth();
};
//ip
PlcClient.InitBootstrap(netInfo.NetAddr, int.Parse(netInfo.NetPort), readTimeout);
PlcClient.InitBootstrap(netInfo.NetAddr, int.Parse(netInfo.NetPort), 30, 30, 30);
/*Task.Run(() =>
{*/
@ -67,7 +67,5 @@ public static class ClientMgr
Log.Error($"conn plc error ={ex.StackTrace}");
}
//});
Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
}
}

@ -33,7 +33,7 @@ public class UpsClient: ModbusTcpMaster
WordSeq= EndingConst.WordSeq.CD;
}
private void BatchRead(ModbusTcpMaster master)
private bool BatchRead(ModbusTcpMaster master)
{
bool resul = Connected;
/*ModbusTcpNet _client = new ModbusTcpNet(master.Ip, master.Port, 0x01);
@ -167,8 +167,9 @@ public class UpsClient: ModbusTcpMaster
FaultHandling(faultDic);
}
return true;
}
/// <summary>

@ -17,7 +17,7 @@
"applicationUrl": "http://localhost:5034",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"profiles_active": "prod"
"profiles_active": "dev"
}
},
"IIS Express": {

Loading…
Cancel
Save