Miglioramenti check online MP7IO e IOB x migliorare fluidità

This commit is contained in:
Samuele E. Locatelli
2019-11-04 12:36:55 +01:00
parent 643c1575ec
commit 6d439106bf
6 changed files with 127 additions and 22 deletions
+8
View File
@@ -46,6 +46,14 @@ namespace IOB_UT
public class baseUtils
{
/// <summary>
/// Variabile in cui viene salvato lo stato del server MP-IO
/// </summary>
public static bool MPIO_Online = false;
/// <summary>
/// Indicazione VETO PING a server sino alla data-ora indicata
/// </summary>
public static DateTime dtVetoPing = DateTime.Now;
/// <summary>
/// Indicazione VETO invio a server sino alla data-ora indicata
/// </summary>
+2 -2
View File
@@ -55,11 +55,11 @@ namespace IOB_WIN
/// <summary>
/// Oggetto x gestione dell'adapter GENERICO (x poter usare metodi di ognuno...)
/// </summary>
IobGeneric iobObj;
public IobGeneric iobObj;
/// <summary>
/// configurazione caricata
/// </summary>
IobConfiguration IOBConf;
public IobConfiguration IOBConf;
/// <summary>
/// tipo di adapter prescelto...
/// </summary>
-1
View File
@@ -9,7 +9,6 @@ NAME=master
;MPIP=192.168.214.4
; Server Steamware
MPIP=10.74.82.218
MPURL=/MP/IO
CMDREBO=/IOB/sendRebootGateway?GWIP=
CMDIOB2CALL=/IOB/getIob2call?GWIP=
+36 -6
View File
@@ -34,7 +34,17 @@ namespace IOB_WIN
/// <summary>
/// Indicazione VETO invio a server sino alla data-ora indicata
/// </summary>
public static DateTime dtVetoPing = DateTime.Now;
public static DateTime dtVetoPing
{
get
{
return utils.dtVetoPing;
}
set
{
utils.dtVetoPing = value;
}
}
/// <summary>
/// Indicazione VETO check status IOB x evitare loop troppo stretti...
/// </summary>
@@ -350,9 +360,19 @@ namespace IOB_WIN
/// </summary>
public bool IobOnline;
/// <summary>
/// stato Online/Offline del server MP IO
/// stato Online/Offline del server MP IO (su utils condiviso)
/// </summary>
public bool MPOnline;
public bool MPOnline
{
get
{
return utils.MPIO_Online;
}
set
{
utils.MPIO_Online = value;
}
}
/// <summary>
/// Dizionario di VC da trattare come TimeSeries (con conf decodificata + processing successivo...)
/// </summary>
@@ -2143,8 +2163,7 @@ namespace IOB_WIN
{
lgInfo("SERVER ONLINE");
parentForm.commSrvActive = 1;
dtVetoPing = DateTime.Now.AddMinutes(-5);
utils.dtVetoSend = DateTime.Now.AddMinutes(-5);
dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec);
}
else
{
@@ -2154,6 +2173,11 @@ namespace IOB_WIN
// salvo nuovo status...
MPOnline = answ;
}
else
{
// allungo periodo controllo...
dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 2);
}
}
else
{
@@ -2193,7 +2217,8 @@ namespace IOB_WIN
try
{
// chiamo URL, se restituisce "OK" è enabled!
answ = (callUrl(urlIobEnabled, true) == "OK");
string callResp = callUrl(urlIobEnabled, false);
answ = (callResp == "OK");
// salvo status...
IobOnline = answ;
// se offline imposto veto check a 5 x tempo reinvio...
@@ -2201,6 +2226,11 @@ namespace IOB_WIN
{
dtVetoCheckIOB = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 5);
}
else
{
// non controllo x meno...
dtVetoCheckIOB = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 1);
}
}
catch
{ }
+80 -12
View File
@@ -78,11 +78,12 @@ namespace IOB_WIN
/// Mostra update delle statistiche di comunicazione (num plc connessi, indirizzo server) con colore ad indicare anomalie...
/// </summary>
/// <param name="numPLC"></param>
/// <param name="numAttivi"></param>
/// <param name="serverOk"></param>
public void updateComStats(int numPLC, bool serverOk)
public void updateComStats(int numPLC, int numAttivi, bool serverOk)
{
// testo
lblComStats.Text = string.Format("{0} PLC --> {1} (MP/IO)", numPLC, MPIP);
lblComStats.Text = $"{numAttivi}/{numPLC} PLC --> {MPIP} (MP/IO)";
// colore secondo valori... server !="ND" è ok, PLC > 0 è OK
int score = 0;
if (serverOk)
@@ -345,7 +346,7 @@ namespace IOB_WIN
IPAddress.TryParse(ipAdrr, out address);
try
{
reply = pingSender.Send(address, 100);
reply = pingSender.Send(address, 200);
answ = reply.Status;
}
catch (Exception exc)
@@ -424,33 +425,99 @@ namespace IOB_WIN
lastComCheck = DateTime.Now;
// conta quanti child form di adapter verso PLC siano aperti !!!FARE!!! chiedere con un metodo che siano ATTIVI e contare quello...
int numPLC = this.MdiChildren.Count<Form>();
int numAttivi = 0;
foreach (var item in this.MdiChildren)
{
try
{
var currForm = (AdapterForm)item;
numAttivi += currForm.iobObj.IobOnline ? 1 : 0;
}
catch
{ }
}
// update stato!
updateComStats(numPLC, testServer);
updateComStats(numPLC, numAttivi, testServer);
}
}
/// <summary>
/// URL per check alive...
/// </summary>
public string urlAlive
{
get
{
return string.Format(@"http://{0}{1}/IOB", MPIP, MPURL);
}
}
/// <summary>
/// Verifica il server: esiste IP, risponde a ping, risponde a pagina ALIVE
/// </summary>
protected bool testServer
public bool testServer
{
get
{
bool answ = false;
// check server: indirizzo esiste
if (MPIP != "")
{
IPAddress address = IPAddress.Loopback;
// check stato server (SOLO PING!)
IPAddress.TryParse(MPIP, out address);
if (address != IPAddress.Loopback)
if (utils.dtVetoPing < DateTime.Now)
{
answ = utils.pingAddress(address);
IPStatus pingStatus = testPingServer;
// se passa il ping faccio il resto...
if (pingStatus == IPStatus.Success)
{
try
{
// chiamo URL, se restituisce "OK" è alive!
string callResp = utils.callUrl(urlAlive);
answ = (callResp == "OK");
}
catch (Exception exc)
{
lgError($"Errore in checkServerAlive:{Environment.NewLine}{exc}");
}
// verifico SE è variato stato online/offline...
if (utils.MPIO_Online != answ)
{
// se ORA sono online riporto...
if (answ)
{
lgInfo("SERVER ONLINE");
utils.dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec);
}
else
{
lgInfo("SERVER OFFLINE");
}
// salvo nuovo status...
utils.MPIO_Online = answ;
}
else
{
// allungo periodo controllo...
utils.dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 2);
}
}
else
{
lgInfo($"SERVER NOT RESPONDING (PING at {MPIP})");
utils.MPIO_Online = false;
// imposto veto a 10 volte reinvio dati standard...
utils.dtVetoPing = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 10);
utils.dtVetoSend = utils.dtVetoPing;
}
}
else
{
// altrimenti passo ultimo valore noto...
answ = utils.MPIO_Online;
}
}
return answ;
}
}
#endregion
#region gestione child form
@@ -780,7 +847,6 @@ namespace IOB_WIN
this.LayoutMdi(MdiLayout.TileHorizontal);
}
#endregion
private void minimizeALLToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -819,5 +885,7 @@ namespace IOB_WIN
lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}");
}
}
#endregion
}
}
Vendored
+1 -1
View File
@@ -16,7 +16,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=488']) {
withEnv(['NEXT_BUILD_NUMBER=489']) {
// env.versionNumber = VersionNumber(versionNumberString : '2.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '2.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'