Completato test: si ferma e riavvia da solo SE si interrompe connessione con PLC!!!
This commit is contained in:
@@ -552,7 +552,7 @@ namespace MTC_Adapter
|
||||
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3}, Dir: {4}", i, (double)(newPos) / utils.CRI("fattdecimale"), i, 0, direzione));
|
||||
sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3} | {4}", i, (double)(newPos) / utils.CRI("fattdecimale"), i, 0, direzione));
|
||||
}
|
||||
|
||||
// salvo valori vettore prec...
|
||||
|
||||
@@ -1638,7 +1638,7 @@ namespace MTC_Adapter
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
|
||||
sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3}, Dir: {4}", valPos.abs.name, (double)(valPos.abs.data) / Math.Pow(10, valPos.abs.dec), valPos.dist.name, (double)(valPos.dist.data) / Math.Pow(10, valPos.dist.dec), direzione));
|
||||
sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3} | {4}", valPos.abs.name, (double)(valPos.abs.data) / Math.Pow(10, valPos.abs.dec), valPos.dist.name, (double)(valPos.dist.data) / Math.Pow(10, valPos.dist.dec), direzione));
|
||||
}
|
||||
|
||||
// salvo valori vettore prec...
|
||||
|
||||
@@ -552,13 +552,17 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public static Logger lg;
|
||||
/// <summary>
|
||||
/// valore booleano di check se sia running
|
||||
/// valore booleano di check se sia in fase di COMUNICAZIONE ATTIVA con il PLC/NC
|
||||
/// </summary>
|
||||
protected bool adpRunning;
|
||||
protected bool adpCommAct;
|
||||
/// <summary>
|
||||
/// valore booleano di check se sia stato AVVIATO l'adapter (Running)
|
||||
/// </summary>
|
||||
public bool adpRunning;
|
||||
/// <summary>
|
||||
/// valore booleano (richiesta di riavvio automatico)
|
||||
/// </summary>
|
||||
protected bool adpTryRestart;
|
||||
public bool adpTryRestart;
|
||||
/// <summary>
|
||||
/// porta x adapter (x restart)
|
||||
/// </summary>
|
||||
@@ -1282,6 +1286,7 @@ namespace MTC_Adapter
|
||||
public virtual void startAdapter(int port)
|
||||
{
|
||||
lg.Info("Starting adapter...");
|
||||
adpRunning = true;
|
||||
dtAvvioAdp = DateTime.Now;
|
||||
// inizializzo vettori di utility..
|
||||
loadAllarmi();
|
||||
@@ -1298,7 +1303,7 @@ namespace MTC_Adapter
|
||||
mStatus.Value = "ON";
|
||||
|
||||
// resetto running flag...
|
||||
adpRunning = false;
|
||||
adpCommAct = false;
|
||||
|
||||
// carico valori da adapter x i conteggi
|
||||
contOreMaccOn = currAdpConf.ContOreMaccOn;
|
||||
@@ -1447,6 +1452,7 @@ namespace MTC_Adapter
|
||||
dtStopAdp = DateTime.Now;
|
||||
adpPortNum = mAdapter.Port;
|
||||
adpTryRestart = tryRestart;
|
||||
adpRunning = false;
|
||||
// chiudo!
|
||||
parentForm.resetProgBar();
|
||||
parentForm.dataMonitor = "... not connected, waiting for data ...";
|
||||
@@ -1463,7 +1469,7 @@ namespace MTC_Adapter
|
||||
if (connectionOk)
|
||||
{
|
||||
// controllo non sia già in esecuzione...
|
||||
if (!adpRunning)
|
||||
if (!adpCommAct)
|
||||
{
|
||||
// provo ad avviare
|
||||
try
|
||||
@@ -1471,16 +1477,16 @@ namespace MTC_Adapter
|
||||
// avvio fase raccolta dati
|
||||
mAdapter.Begin();
|
||||
// imposto flag adapter running..
|
||||
adpRunning = true;
|
||||
adpCommAct = true;
|
||||
adpStartRun = DateTime.Now;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
parentForm.displayTaskAndWait(string.Format("Adapter NOT STARTED!!!{0}{1}", Environment.NewLine, exc));
|
||||
adpRunning = false;
|
||||
adpCommAct = false;
|
||||
adpStartRun = DateTime.Now;
|
||||
}
|
||||
if (adpRunning)
|
||||
if (adpCommAct)
|
||||
{
|
||||
// try / catch generale altrimenti segno che è disconnesso...
|
||||
try
|
||||
@@ -1541,7 +1547,7 @@ namespace MTC_Adapter
|
||||
parentForm.fermaAdapter(true);
|
||||
}
|
||||
// tolgo flag running
|
||||
adpRunning = false;
|
||||
adpCommAct = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1556,7 +1562,7 @@ namespace MTC_Adapter
|
||||
if (DateTime.Now.Subtract(adpStartRun).TotalSeconds > utils.CRI("maxAdapterLockSec"))
|
||||
{
|
||||
// tolgo flag running
|
||||
adpRunning = false;
|
||||
adpCommAct = false;
|
||||
adpStartRun = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,11 @@
|
||||
<add key="autoLoadConf" value="false" />
|
||||
<add key="autoStartOnLoad" value="true" />
|
||||
<add key="openDumpOnStart" value="true" />
|
||||
<add key="startMinimized" value="true" />
|
||||
<add key="startMinimized" value="false" />
|
||||
<add key="windowCanMax" value="true" />
|
||||
<add key="trayClose" value="true" />
|
||||
<add key="autoSaveSec" value="60" />
|
||||
<add key="waitRecMSec" value="1000" />
|
||||
|
||||
<add key="testCharSep" value="|" />
|
||||
<add key="fattdecimale" value="1000" />
|
||||
|
||||
@@ -48,6 +48,10 @@ namespace MTC_Adapter
|
||||
/// timer base in avvio
|
||||
/// </summary>
|
||||
protected int startTimerMs;
|
||||
/// <summary>
|
||||
/// ultimo tentativo riavvio...
|
||||
/// </summary>
|
||||
protected DateTime lastStartTry;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -120,6 +124,8 @@ namespace MTC_Adapter
|
||||
InitializeComponent();
|
||||
lblStatus.Text = "Loading";
|
||||
|
||||
lastStartTry = DateTime.Now;
|
||||
|
||||
// fix icon!
|
||||
Icon = Icon.ExtractAssociatedIcon(defIconFilePath);
|
||||
notifyIcon1.Icon = Icon.ExtractAssociatedIcon(defIconFilePath);
|
||||
@@ -151,6 +157,10 @@ namespace MTC_Adapter
|
||||
loadAdapterType();
|
||||
displayTaskAndWait("Waiting for config file selection");
|
||||
}
|
||||
|
||||
// Start timer periodico
|
||||
gather.Interval = utils.CRI("timerIntMs");
|
||||
gather.Enabled = true;
|
||||
|
||||
displayTaskAndWait("Running");
|
||||
createTrayMenu();
|
||||
@@ -458,10 +468,6 @@ namespace MTC_Adapter
|
||||
}
|
||||
|
||||
displayTaskAndWait("Start Timers");
|
||||
|
||||
// Start timer periodico
|
||||
gather.Interval = utils.CRI("timerIntMs");
|
||||
gather.Enabled = true;
|
||||
// inizializzo contatori fast/mid/slow
|
||||
fastCount = utils.CRI("fastCount");
|
||||
normCount = utils.CRI("normCount");
|
||||
@@ -494,33 +500,48 @@ namespace MTC_Adapter
|
||||
stop.Enabled = false;
|
||||
dump.Enabled = false;
|
||||
start.Enabled = true;
|
||||
gather.Enabled = false;
|
||||
//gather.Enabled = false;
|
||||
}
|
||||
|
||||
private void gather_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// inizio a riportare che sto eseguendo..
|
||||
MainProgrBar.PerformStep();
|
||||
|
||||
// eseguo eventuali simulazioni x dati/flags SE RICHIESTO
|
||||
simulateData();
|
||||
|
||||
// check esecuzione FastTask
|
||||
checkFastTask();
|
||||
|
||||
// check esecuzione NormTask
|
||||
checkNormTask();
|
||||
|
||||
// check esecuzione SlowTask
|
||||
checkSlowTask();
|
||||
|
||||
// check esecuzione AlarmSync
|
||||
checkAlarmSync();
|
||||
|
||||
// se è arrivato a MAX resetto...
|
||||
if (MainProgrBar.Value >= MainProgrBar.Maximum)
|
||||
|
||||
// eseguo cicli attivi SOLO se adapter è in EFFETTIVO running...
|
||||
if (agObj.adpRunning)
|
||||
{
|
||||
MainProgrBar.Value = 0;
|
||||
// inizio a riportare che sto eseguendo..
|
||||
MainProgrBar.PerformStep();
|
||||
|
||||
// eseguo eventuali simulazioni x dati/flags SE RICHIESTO
|
||||
simulateData();
|
||||
|
||||
// check esecuzione FastTask
|
||||
checkFastTask();
|
||||
|
||||
// check esecuzione NormTask
|
||||
checkNormTask();
|
||||
|
||||
// check esecuzione SlowTask
|
||||
checkSlowTask();
|
||||
|
||||
// check esecuzione AlarmSync
|
||||
checkAlarmSync();
|
||||
|
||||
// se è arrivato a MAX resetto...
|
||||
if (MainProgrBar.Value >= MainProgrBar.Maximum)
|
||||
{
|
||||
MainProgrBar.Value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// verifico SE debba tentare il riavvio, ovvero NON running ma tryReconn e non ho riprovato x oltre waitRecMSec
|
||||
int currWait = DateTime.Now.Subtract(lastStartTry).Milliseconds;
|
||||
if (agObj.adpTryRestart && currWait> utils.CRI("waitRecSec"))
|
||||
{
|
||||
lastStartTry = DateTime.Now;
|
||||
avviaAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user