Inizio modifica PLC SiemensTOrri x derivare da Siemens x irrobustire
This commit is contained in:
@@ -373,9 +373,10 @@ namespace IOB_WIN
|
||||
}
|
||||
else
|
||||
{
|
||||
double currWait = DateTime.Now.Subtract(lastStartTry).TotalMilliseconds;
|
||||
if (iobObj.adpTryRestart && currWait > utils.CRI("waitRecMSec"))
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(utils.CRI("waitRecMSec"));
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
||||
{
|
||||
lgInfo("Retry Time Elapsed --> tryConnect");
|
||||
lastStartTry = DateTime.Now;
|
||||
iobObj.tryConnect();
|
||||
}
|
||||
@@ -383,13 +384,13 @@ namespace IOB_WIN
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iobObj.verboseLog)
|
||||
if (iobObj.periodicLog)
|
||||
{
|
||||
lgInfo("PLC <--> IOB Not connected");
|
||||
lgInfo("Adapter stopped");
|
||||
}
|
||||
// verifico SE debba tentare il riavvio, ovvero NON running ma tryReconn e non ho riprovato x oltre waitRecMSec
|
||||
double currWait = DateTime.Now.Subtract(lastStartTry).TotalMilliseconds;
|
||||
if (iobObj.adpTryRestart && currWait > utils.CRI("waitRecMSec"))
|
||||
// verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart e non ho riprovato x oltre waitRecMSec
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(utils.CRI("waitRecMSec"));
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
||||
{
|
||||
lastStartTry = DateTime.Now;
|
||||
avviaAdapter(chkForceDequeue.Checked);
|
||||
|
||||
@@ -364,6 +364,7 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
{
|
||||
bool doLog = (verboseLog || periodicLog);
|
||||
if (!connectionOk)
|
||||
{
|
||||
// reimporto parametri PLC se necessario...
|
||||
@@ -371,7 +372,7 @@ namespace IOB_WIN
|
||||
// controllo che il ping sia stato tentato almeno pingTestSec fa...
|
||||
if (DateTime.Now.Subtract(lastPING).TotalSeconds > utils.CRI("pingTestSec"))
|
||||
{
|
||||
if (verboseLog || periodicLog)
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo("SIEMENS: ConnKO - tryConnect");
|
||||
}
|
||||
@@ -420,7 +421,7 @@ namespace IOB_WIN
|
||||
{
|
||||
// loggo no risposta ping ...
|
||||
connectionOk = false;
|
||||
if (verboseLog || periodicLog)
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo(string.Format("Attenzione: SIEMENS controllo PING fallito per IP {0}", cIobConf.cncIpAddr));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace IOB_WIN
|
||||
@@ -34,10 +33,6 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
protected Plc currPLC;
|
||||
/// <summary>
|
||||
/// indica se serva refresh parametri e quindi PLC...
|
||||
/// </summary>
|
||||
bool needRefresh = true;
|
||||
/// <summary>
|
||||
/// Oggetto cronometro x test vari...
|
||||
/// </summary>
|
||||
protected Stopwatch sw = new Stopwatch();
|
||||
@@ -235,23 +230,6 @@ namespace IOB_WIN
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// test ping all'indirizzo impostato nei parametri
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IPStatus testPing()
|
||||
{
|
||||
IPStatus answ = IPStatus.Unknown; ;
|
||||
IPAddress address;
|
||||
PingReply reply;
|
||||
Ping pingSender = new Ping();
|
||||
address = IPAddress.Loopback;
|
||||
IPAddress.TryParse(parametri.ipAdrr, out address);
|
||||
int pingMsTimeout = parametri.pingMsTimeout;
|
||||
reply = pingSender.Send(address, pingMsTimeout);
|
||||
answ = reply.Status;
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Imposto parametri PLC
|
||||
/// </summary>
|
||||
private void setParamPlc()
|
||||
@@ -381,12 +359,15 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
{
|
||||
bool doLog = (verboseLog || periodicLog);
|
||||
if (!connectionOk)
|
||||
{
|
||||
// reimporto parametri PLC se necessario...
|
||||
setParamPlc();
|
||||
// controllo che il ping sia stato tentato almeno pingTestSec fa...
|
||||
if (DateTime.Now.Subtract(lastPING).TotalSeconds > utils.CRI("pingTestSec"))
|
||||
{
|
||||
if (verboseLog || periodicLog)
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo("SIEMENS-TORRI: ConnKO - tryConnect");
|
||||
}
|
||||
@@ -435,7 +416,7 @@ namespace IOB_WIN
|
||||
{
|
||||
// loggo no risposta ping ...
|
||||
connectionOk = false;
|
||||
if (verboseLog || periodicLog)
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo(string.Format("Attenzione: SIEMENS-TORRI controllo PING fallito per IP {0}", cIobConf.cncIpAddr));
|
||||
}
|
||||
@@ -757,7 +738,7 @@ namespace IOB_WIN
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
|
||||
Reference in New Issue
Block a user