Update x gestione verbosità app con ping fallito...
This commit is contained in:
+3
-2
@@ -24,6 +24,7 @@
|
||||
<add key="sampleMemCount" value="6000" />
|
||||
<add key="waitEndCycle" value="0" />
|
||||
<!-- watchdog -->
|
||||
<add key="pingTestSec" value="5" />
|
||||
<add key="watchdogMaxSec" value="59" />
|
||||
<!--Modalità DEMO: DemoOUT indica che NON invia davvero al server e DemoIN che simula e NON legge da PLC-->
|
||||
<add key="DemoIn" value="false" />
|
||||
@@ -57,9 +58,9 @@
|
||||
<!--logging-->
|
||||
<add key="recTime" value="true" />
|
||||
<add key="verbose" value="false" />
|
||||
<add key="logEvery" value="1" />
|
||||
<add key="logEvery" value="2" />
|
||||
<add key="numRowConsole" value="20" />
|
||||
<add key="verboseLogTOut" value="5" />
|
||||
<add key="verboseLogTOut" value="30" />
|
||||
<!--conf x testing FANUC-->
|
||||
<add key="macOnFromConn" value="true" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
|
||||
+41
-34
@@ -131,56 +131,63 @@ namespace IOB_WIN
|
||||
{
|
||||
if (!connectionOk)
|
||||
{
|
||||
// in primis PING!!!
|
||||
Ping pingSender = new Ping();
|
||||
IPAddress address = IPAddress.Loopback;
|
||||
IPAddress.TryParse(currIobConf.cncIpAddr, out address);
|
||||
PingReply reply = pingSender.Send(address);
|
||||
// se passa il ping faccio il resto...
|
||||
if (reply.Status == IPStatus.Success)
|
||||
// controllo che il ping sia stato tentato almeno pingTestSec fa...
|
||||
if (DateTime.Now.Subtract(lastPING).TotalSeconds > utils.CRI("pingTestSec"))
|
||||
{
|
||||
string szStatusConnection = "";
|
||||
try
|
||||
if (verboseLog || periodicLog) lg.Info("ConnKO - tryConnect");
|
||||
// in primis salvo data ping...
|
||||
lastPING = DateTime.Now;
|
||||
// ora PING!!!
|
||||
Ping pingSender = new Ping();
|
||||
IPAddress address = IPAddress.Loopback;
|
||||
IPAddress.TryParse(currIobConf.cncIpAddr, out address);
|
||||
PingReply reply = pingSender.Send(address, 100);
|
||||
// se passa il ping faccio il resto...
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
// ora provo connessione...
|
||||
parentForm.commPlcActive = true;
|
||||
FANUC_ref.Connect(ref szStatusConnection);
|
||||
parentForm.commPlcActive = false;
|
||||
lg.Info("szStatusConnection: " + szStatusConnection);
|
||||
connectionOk = true;
|
||||
// refresh stato allarmi!!!
|
||||
if (connectionOk)
|
||||
string szStatusConnection = "";
|
||||
try
|
||||
{
|
||||
if (adpRunning)
|
||||
// ora provo connessione...
|
||||
parentForm.commPlcActive = true;
|
||||
FANUC_ref.Connect(ref szStatusConnection);
|
||||
parentForm.commPlcActive = false;
|
||||
lg.Info("szStatusConnection: " + szStatusConnection);
|
||||
connectionOk = true;
|
||||
// refresh stato allarmi!!!
|
||||
if (connectionOk)
|
||||
{
|
||||
// carico status allarmi (completo)
|
||||
lg.Info("Inizio refresh completo stato allarmi...");
|
||||
forceAlarmCheck();
|
||||
lg.Info("Completato refresh completo stato allarmi!");
|
||||
if (adpRunning)
|
||||
{
|
||||
// carico status allarmi (completo)
|
||||
lg.Info("Inizio refresh completo stato allarmi...");
|
||||
forceAlarmCheck();
|
||||
lg.Info("Completato refresh completo stato allarmi!");
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Info("Connessione OK");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Info("Connessione OK");
|
||||
lg.Error("Impossibile procedere, connessione mancante...");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error("Impossibile procedere, connessione mancante...");
|
||||
lg.Fatal(string.Format("Errore nella connessione all'adapter FANUC: {0}{1}{2}", szStatusConnection, Environment.NewLine, exc));
|
||||
connectionOk = false;
|
||||
lg.Info(string.Format("Eccezione in TryConnect, Adapter NON running, pausa di {0} msec prima di ulteriori tentativi di riconnessione", utils.CRI("waitRecMSec")));
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
else
|
||||
{
|
||||
lg.Fatal(string.Format("Errore nella connessione all'adapter FANUC: {0}{1}{2}", szStatusConnection, Environment.NewLine, exc));
|
||||
// loggo no risposta ping ...
|
||||
connectionOk = false;
|
||||
lg.Info(string.Format("Eccezione in TryConnect, Adapter NON running, pausa di {0} msec prima di ulteriori tentativi di riconnessione", utils.CRI("waitRecMSec")));
|
||||
if (verboseLog || periodicLog) lg.Info(string.Format("Attenzione: controllo PING fallito per IP {0} - {1}", currIobConf.cncIpAddr, reply.Status));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loggo no risposta ping ...
|
||||
connectionOk = false;
|
||||
lg.Info(string.Format("Attenzione: controllo PING fallito per IP {0} - {1}", currIobConf.cncIpAddr, reply.Status));
|
||||
}
|
||||
}
|
||||
// se non è ancora connesso faccio procesisng memoria caso disconnesso...
|
||||
if (!connectionOk)
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public DateTime lastWatchDog;
|
||||
/// <summary>
|
||||
/// dataOra ultimo PING inviato...
|
||||
/// </summary>
|
||||
public DateTime lastPING;
|
||||
/// <summary>
|
||||
/// Oggetto della coda degli elementi letti (e non ancora trasmessi)
|
||||
/// </summary>
|
||||
public Queue<string> QueueIN = new Queue<string>();
|
||||
@@ -338,6 +342,7 @@ namespace IOB_WIN
|
||||
adpRunning = true;
|
||||
dtAvvioAdp = DateTime.Now;
|
||||
lastWatchDog = dtAvvioAdp;
|
||||
lastPING = dtAvvioAdp;
|
||||
TimingData.resetData();
|
||||
// aggiungo altri defaults
|
||||
setDefaults();
|
||||
@@ -490,12 +495,9 @@ namespace IOB_WIN
|
||||
}
|
||||
else
|
||||
{
|
||||
// log connessione KO
|
||||
lg.Error("getAndSend - Connessione non disponibile, provo a riconnettere");
|
||||
// provo a riconnettere SE abilitato tryRestart...
|
||||
if (adpTryRestart && !connectionOk)
|
||||
{
|
||||
lg.Info("ConnKO - tryConnect");
|
||||
tryConnect();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user