rollback to the public version ofthe udp listener
This commit is contained in:
parent
3539dae3a1
commit
a4b34de954
|
@ -9,7 +9,7 @@ namespace InnovEnergy.App.SaliMax.MiddlewareClasses;
|
||||||
|
|
||||||
public static class MiddlewareAgent
|
public static class MiddlewareAgent
|
||||||
{
|
{
|
||||||
public static UdpClient UdpListener = null!;
|
private static UdpClient _udpListener = null!;
|
||||||
private static IPAddress? _controllerIpAddress;
|
private static IPAddress? _controllerIpAddress;
|
||||||
private static EndPoint? _endPoint;
|
private static EndPoint? _endPoint;
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ public static class MiddlewareAgent
|
||||||
const Int32 udpPort = 9000;
|
const Int32 udpPort = 9000;
|
||||||
_endPoint = new IPEndPoint(_controllerIpAddress, udpPort);
|
_endPoint = new IPEndPoint(_controllerIpAddress, udpPort);
|
||||||
|
|
||||||
UdpListener = new UdpClient();
|
_udpListener = new UdpClient();
|
||||||
UdpListener.Client.Blocking = false;
|
_udpListener.Client.Blocking = false;
|
||||||
UdpListener.Client.Bind(_endPoint);
|
_udpListener.Client.Bind(_endPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IPAddress FindVpnIp()
|
private static IPAddress FindVpnIp()
|
||||||
|
@ -53,7 +53,7 @@ public static class MiddlewareAgent
|
||||||
|
|
||||||
public static Configuration? SetConfigurationFile()
|
public static Configuration? SetConfigurationFile()
|
||||||
{
|
{
|
||||||
if (UdpListener.Available > 0)
|
if (_udpListener.Available > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
IPEndPoint? serverEndpoint = null;
|
IPEndPoint? serverEndpoint = null;
|
||||||
|
@ -61,7 +61,7 @@ public static class MiddlewareAgent
|
||||||
var replyMessage = "ACK";
|
var replyMessage = "ACK";
|
||||||
var replyData = Encoding.UTF8.GetBytes(replyMessage);
|
var replyData = Encoding.UTF8.GetBytes(replyMessage);
|
||||||
|
|
||||||
var udpMessage = UdpListener.Receive(ref serverEndpoint);
|
var udpMessage = _udpListener.Receive(ref serverEndpoint);
|
||||||
var message = Encoding.UTF8.GetString(udpMessage);
|
var message = Encoding.UTF8.GetString(udpMessage);
|
||||||
|
|
||||||
var config = JsonSerializer.Deserialize<Configuration>(message);
|
var config = JsonSerializer.Deserialize<Configuration>(message);
|
||||||
|
@ -74,13 +74,13 @@ public static class MiddlewareAgent
|
||||||
config.CalibrationChargeDate);
|
config.CalibrationChargeDate);
|
||||||
|
|
||||||
// Send the reply to the sender's endpoint
|
// Send the reply to the sender's endpoint
|
||||||
UdpListener.Send(replyData, replyData.Length, serverEndpoint);
|
_udpListener.Send(replyData, replyData.Length, serverEndpoint);
|
||||||
Console.WriteLine($"Replied to {serverEndpoint}: {replyMessage}");
|
Console.WriteLine($"Replied to {serverEndpoint}: {replyMessage}");
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_endPoint != null && !_endPoint.Equals(UdpListener.Client.LocalEndPoint as IPEndPoint))
|
if (_endPoint != null && !_endPoint.Equals(_udpListener.Client.LocalEndPoint as IPEndPoint))
|
||||||
{
|
{
|
||||||
Console.WriteLine("UDP address has changed, rebinding...");
|
Console.WriteLine("UDP address has changed, rebinding...");
|
||||||
InitializeCommunicationToMiddleware();
|
InitializeCommunicationToMiddleware();
|
||||||
|
|
|
@ -593,7 +593,7 @@ internal static class Program
|
||||||
if (upperVoltage <= configFile.GridTie.AcDc.MaxDcLinkVoltage)
|
if (upperVoltage <= configFile.GridTie.AcDc.MaxDcLinkVoltage)
|
||||||
{
|
{
|
||||||
_curtailFlag = false;
|
_curtailFlag = false;
|
||||||
upperVoltage = configFile.GridTie.AcDc.MaxDcLinkVoltage;
|
upperVoltage = configFile.GridTie.AcDc.MaxDcLinkVoltage;
|
||||||
upperVoltage.WriteLine(" New Upper limit");
|
upperVoltage.WriteLine(" New Upper limit");
|
||||||
Console.WriteLine("Upper Voltage decreased: Smaller than the default value, value clamped");
|
Console.WriteLine("Upper Voltage decreased: Smaller than the default value, value clamped");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue