Ultimi fix x retry PING (da rivedere)
da rivedere se convenga togliere controllo ping server in TANTI punti...
This commit is contained in:
+15
-5
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -2496,13 +2497,22 @@ namespace IOB_WIN
|
||||
PingReply reply;
|
||||
Ping pingSender = new Ping();
|
||||
address = IPAddress.Loopback;
|
||||
int maxRetry = 5;
|
||||
int numRetry = 1; ;
|
||||
string ipAdrr = cIobConf.serverData.MPIP.Replace("http://", "").Replace("https://", "");
|
||||
IPAddress.TryParse(ipAdrr, out address);
|
||||
reply = pingSender.Send(address, pingServerMsTimeout);
|
||||
// se ho timeout riprovo...
|
||||
if (reply.Status == IPStatus.TimedOut)
|
||||
reply = pingSender.Send(address, pingServerMsTimeout);
|
||||
// se ho timeout riprovo...
|
||||
while (reply.Status != IPStatus.Success && numRetry < maxRetry)
|
||||
{
|
||||
reply = pingSender.Send(address, pingServerMsTimeout);
|
||||
lgInfo($"Ping KO | reply: {reply.Status} --> retry");
|
||||
reply = pingSender.Send(address, pingServerMsTimeout * numRetry / 2);
|
||||
numRetry++;
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
lgInfo("PING OK!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
answ = reply.Status;
|
||||
return answ;
|
||||
@@ -2568,7 +2578,7 @@ namespace IOB_WIN
|
||||
lgInfo($"SERVER NOT RESPONDING (PING at {cIobConf.serverData.MPIP})");
|
||||
MPOnline = false;
|
||||
// imposto veto a 10 volte reinvio dati standard...
|
||||
dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 10);
|
||||
dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 3);
|
||||
utils.dtVetoSend = dtVetoPing;
|
||||
}
|
||||
}
|
||||
|
||||
+30
-28
@@ -781,40 +781,42 @@ namespace IOB_WIN
|
||||
OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 0, 8, out memReadDM);
|
||||
OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.WR, 0, 8, out memReadWR);
|
||||
|
||||
lgInfo("Effettuata lettura dati CIO");
|
||||
foreach (var item in memReadCIO_IN)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("Effettuata lettura dati CIO");
|
||||
foreach (var item in memReadCIO_IN)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
lgInfo("Effettuata lettura dati DM");
|
||||
foreach (var item in memReadDM)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
lgInfo("Effettuata lettura dati WR");
|
||||
foreach (var item in memReadWR)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
}
|
||||
lgInfo("Effettuata lettura dati DM");
|
||||
foreach (var item in memReadDM)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
lgInfo("Effettuata lettura dati WR");
|
||||
foreach (var item in memReadWR)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
short[] respDM20;
|
||||
short[] respDM22;
|
||||
OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 20, 2, out respDM20);
|
||||
OMRON_ref.ReadWords(OmronFinsTCP.Net.PlcMemory.DM, 22, 2, out respDM22);
|
||||
// legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa)
|
||||
lgInfo("Effettuata lettura dati respDM20");
|
||||
foreach (var item in respDM20)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
// legge delle coppie di valori INT, vanno trasformati in HEX e POI accodati, dove il primo è x 1 e il secondo x 10000 (in pratica va in testa)
|
||||
lgInfo("Effettuata lettura dati respDM20");
|
||||
foreach (var item in respDM20)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
lgInfo("Effettuata lettura dati respDM22");
|
||||
foreach (var item in respDM22)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
}
|
||||
lgInfo("Effettuata lettura dati respDM22");
|
||||
foreach (var item in respDM22)
|
||||
{
|
||||
lgInfo($"Valori: {item} --> {baseUtils.binaryForm(item)}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user