diff --git a/IOB-UT/baseUtils.cs b/IOB-UT/baseUtils.cs
index 2a3e4fd8..839829c8 100644
--- a/IOB-UT/baseUtils.cs
+++ b/IOB-UT/baseUtils.cs
@@ -14,9 +14,18 @@ namespace IOB_UT
public class baseUtils
{
///
- /// classe logger
+ /// Indicazione VETO invio a server sino alla data-ora indicata
///
- public static Logger lg;
+ public static DateTime dtVetoSend = DateTime.Now;
+
+ ///
+ /// oggetto static x gestione baseUtils
+ ///
+ public static baseUtils mgr = new baseUtils();
+ ///
+ /// Fattore di riduzione dei log
+ ///
+ public static int logReduxFactor = 10;
///
/// legge conf in formato char
@@ -302,6 +311,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
+ Logger lg = LogManager.GetCurrentClassLogger();
lg.Info(exc, string.Format("Errore in scrittura file {0}", file));
}
}
@@ -380,6 +390,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
+ Logger lg = LogManager.GetCurrentClassLogger();
lg.Error(exc);
}
return sIpAddr;
@@ -411,10 +422,38 @@ namespace IOB_UT
public static string callUrl(string URL)
{
string answ = "";
- var client = new WebClient();
- client.Headers.Add("user-agent", CRS("appName"));
- answ = client.DownloadString(URL);
- // restituisco valore!
+ // controllo se ho un VETO all'invio...
+ if (dtVetoSend < DateTime.Now)
+ {
+ var client = new WebClient();
+ client.Headers.Add("user-agent", CRS("appName"));
+ try
+ {
+ answ = client.DownloadString(URL);
+ }
+ catch (Exception exc)
+ {
+ // imposto un veto per pauseSendMSec
+ int pauseSendMSec = CRI("pauseSendMSec");
+ // aggiungo NOISE... +/- 20%
+ Random rnd = new Random();
+ int noise = rnd.Next(1, pauseSendMSec / 5);
+ pauseSendMSec += noise - (pauseSendMSec / 10);
+ // imposto veto
+ dtVetoSend = DateTime.Now.AddMilliseconds(pauseSendMSec);
+
+ // log ogni
+ Logger lg = LogManager.GetCurrentClassLogger();
+ lg.Info("Errore in callURL: impostato attesa di {0} ms prima della prossima chiamata", pauseSendMSec);
+ logReduxFactor--;
+ if (logReduxFactor <= 0)
+ {
+ lg.Error("Eccezione in esecuzione callURL: {0}{1}{2}", URL, Environment.NewLine, exc);
+ logReduxFactor = 10;
+ }
+ }
+ // restituisco valore!
+ }
return answ;
}
}
diff --git a/IOB-WIN/AdapterForm.Designer.cs b/IOB-WIN/AdapterForm.Designer.cs
index be704c66..0fbef0dd 100644
--- a/IOB-WIN/AdapterForm.Designer.cs
+++ b/IOB-WIN/AdapterForm.Designer.cs
@@ -124,8 +124,8 @@
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 55F));
- this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25F));
- this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 45F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 45F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.tableLayoutPanel1.Controls.Add(this.restart, 0, 0);
@@ -166,7 +166,7 @@
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(985, 0);
+ this.label6.Location = new System.Drawing.Point(970, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(48, 37);
this.label6.TabIndex = 76;
@@ -282,9 +282,9 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.lQueueLen.AutoSize = true;
this.lQueueLen.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lQueueLen.Location = new System.Drawing.Point(1039, 0);
+ this.lQueueLen.Location = new System.Drawing.Point(1024, 0);
this.lQueueLen.Name = "lQueueLen";
- this.lQueueLen.Size = new System.Drawing.Size(19, 37);
+ this.lQueueLen.Size = new System.Drawing.Size(39, 37);
this.lQueueLen.TabIndex = 77;
this.lQueueLen.Text = "#";
this.lQueueLen.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -432,7 +432,7 @@
this.lblDataProc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblDataProc.AutoSize = true;
- this.lblDataProc.Location = new System.Drawing.Point(965, 0);
+ this.lblDataProc.Location = new System.Drawing.Point(950, 0);
this.lblDataProc.Name = "lblDataProc";
this.lblDataProc.Size = new System.Drawing.Size(13, 37);
this.lblDataProc.TabIndex = 79;
diff --git a/IOB-WIN/AdapterForm.cs b/IOB-WIN/AdapterForm.cs
index 34f26f17..861bf45b 100644
--- a/IOB-WIN/AdapterForm.cs
+++ b/IOB-WIN/AdapterForm.cs
@@ -221,7 +221,7 @@ namespace IOB_WIN
// verifico server online...
if (iobObj.checkServerAlive)
{
- // segnalo reboot (programma)...
+ // segnalo reboot (programma)...
iobObj.callUrl(iobObj.urlReboot);
}
else
@@ -689,14 +689,29 @@ namespace IOB_WIN
}
}
///
- /// Visualizzazione stato di comunicazione attiva con PLC
+ /// Visualizzazione stato di comunicazione attiva con PLC:
+ /// 0 = NO PING
+ /// 1 = PING OK
+ /// 2 = MP/IO OK
///
- public bool commSrvActive
+ public int commSrvActive
{
set
{
- // se true --> comunica/verde, altrimenti grigio
- lblSrvUrl.ForeColor = value ? Color.SeaGreen : Color.Red;
+ switch (value)
+ {
+ case 0:
+ lblSrvUrl.ForeColor = Color.Red;
+ break;
+ case 1:
+ lblSrvUrl.ForeColor = Color.OrangeRed;
+ break;
+ case 2:
+ lblSrvUrl.ForeColor = Color.SeaGreen;
+ break;
+ default:
+ break;
+ }
statusStrip1.Refresh();
}
}
diff --git a/IOB-WIN/App.config b/IOB-WIN/App.config
index 92319c4c..4252b580 100644
--- a/IOB-WIN/App.config
+++ b/IOB-WIN/App.config
@@ -31,6 +31,7 @@
+
diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs
index 26da0541..475445ad 100644
--- a/IOB-WIN/IobGeneric.cs
+++ b/IOB-WIN/IobGeneric.cs
@@ -328,6 +328,10 @@ namespace IOB_WIN
///
protected bool needRefresh = true;
///
+ /// Indicazione VETO invio a server sino alla data-ora indicata
+ ///
+ public DateTime dtVetoSend = DateTime.Now;
+ ///
/// inizializzo l'oggetto sulla form SULLA BASE DEL FILE DI CONFIGURAZIONE letto
///
///
@@ -1147,97 +1151,6 @@ namespace IOB_WIN
{
}
-#if false
- #region area simulazione
-
- ///
- /// lettura memoria in SIMULAZIONE
- ///
- public void simReadMem()
- {
- if (lastSim == null)
- {
- lastSim = DateTime.Now;
- }
- // simulazione complessa (basata su samples dei parametri effettivi...)
- if (utils.CRB("DemoInSample"))
- {
- if (numSim >= 0)
- {
- // verifico se la coda di simulazione sia piena altrimenti la RICARICO...
- if (QueueSIM.Count == 0)
- {
- leggiSimFile();
- numSim--;
- }
- // processo la coda di simulazione (stacco ed accodo 1 valore...)
- B_input = QueueSIM.Dequeue();
- countSim++;
- // ogni 5 loggo...
- if (countSim % 5 == 0)
- {
- lgInfo("Read {0} sim data", countSim);
- }
- }
- else
- {
- // fermo tutto!
- parentForm.sIN = Semaforo.SR;
- parentForm.fermaAdapter(false);
- }
- }
- // simulazione semplice (counter crescente)
- else
- {
- // se passato 1 sec genero NUOV num casuale e lo metto nel bit strobe... ogni 2 sec...
- if (DateTime.Now.Subtract(lastSim).TotalMilliseconds > 100)
- {
- countSim++;
- if (countSim > 255)
- {
- countSim = 0;
- }
-
- B_input = countSim;
- }
- }
- lastSim = DateTime.Now;
- }
- ///
- /// legge ed accoda file Sim in QueueSIM
- ///
- private void leggiSimFile()
- {
- int totRighe = 0;
- string fileName = utils.simDataFile;
- string linea;
- totRighe = File.ReadLines(fileName).Count();
- lgInfo("File SIM: TROVATE {0} righe", totRighe);
- // ora conto righe effettive...
- totRighe = 0;
- // carica da file...
- StreamReader file = new StreamReader(fileName);
- // leggo 1 linea alla volta...
- int valore = 0;
- while ((linea = file.ReadLine()) != null)
- {
- // SE non è un commento...
- if (linea.Substring(0, 1) != ";")
- {
- //elencoAllarmi[rumRiga] = decodeAlarmLine(linea, ':');
- Int32.TryParse(linea, out valore);
- QueueSIM.Enqueue(valore);
- totRighe++;
- }
- }
- // chiudo file
- file.Close();
- lgInfo("File SIM: LETTE {0} righe", totRighe);
- }
-
- #endregion
-#endif
-
#region IOB METHODS
///
@@ -1436,6 +1349,7 @@ namespace IOB_WIN
answ += string.Format(@"&&dtEve={0}&&dtCurr={1:yyyyMMddHHmmssfff}&&cnt={2}", valori[0], DateTime.Now, valori[3]);
return answ;
}
+
///
/// Effettua chiamata URL e restituisce risultato
///
@@ -1443,12 +1357,7 @@ namespace IOB_WIN
///
public string callUrl(string URL)
{
- string answ = "";
- var client = new WebClient();
- client.Headers.Add("user-agent", utils.CRS("appName"));
- answ = client.DownloadString(URL);
- // restituisco valore!
- return answ;
+ return utils.callUrl(URL);
}
///
/// test ping all'indirizzo impostato nei parametri
@@ -1469,7 +1378,7 @@ namespace IOB_WIN
return answ;
}
///
- /// Verifica se il server sia ALIVE
+ /// Verifica se il server sia ALIVE (tramite PING)
///
public bool checkServerAlive
{
@@ -1502,12 +1411,12 @@ namespace IOB_WIN
if (answ)
{
lgInfo("SERVER ONLINE");
- parentForm.commSrvActive = true;
+ parentForm.commSrvActive = 1;
}
else
{
lgInfo("SERVER OFFLINE");
- parentForm.commSrvActive = false;
+ parentForm.commSrvActive = 0;
}
// salvo nuovo status...
MPOnline = answ;
@@ -1558,6 +1467,15 @@ namespace IOB_WIN
// salvo nuovo status...
IobOnline = answ;
}
+ // fix colore
+ if (answ)
+ {
+ parentForm.commSrvActive = 2;
+ }
+ else
+ {
+ parentForm.commSrvActive = 1;
+ }
return answ;
}
}
@@ -1625,10 +1543,8 @@ namespace IOB_WIN
//controllo se è passato oltre watchdog e non ho inviato nulla --> RE-INVIO (ultimo inviato)!!!!
if (DateTime.Now.Subtract(lastWatchDog).TotalSeconds > utils.CRI("watchdogMaxSec"))
{
-
string wdStatus = "elapsed";
string sVal = string.Format("[WDST]{0}", wdStatus);
-
// chiamo accodamento...
accodaFLog(sVal, qEncodeFLog("WDST", wdStatus));
lastWatchDog = DateTime.Now;
diff --git a/IOB-WIN/IobSimula.cs b/IOB-WIN/IobSimula.cs
index 43a7486b..f1edca55 100644
--- a/IOB-WIN/IobSimula.cs
+++ b/IOB-WIN/IobSimula.cs
@@ -206,16 +206,20 @@ namespace IOB_WIN
}
if (sendContapezzi)
{
- // invio a server contapezzi (aggiornato)
- string retVal = utils.callUrl(urlSetPzCount + contapezzi.ToString());
- // verifica se tutto OK
- if (retVal != "OK")
+ // controllo se ALMENO sia pingabile il server
+ if (checkServerAlive)
{
- // errore salvataggio contapezzi
- lgInfo(string.Format("Errore salvataggio Contapezzi SIMULAZIONE {0} | Errore salvataggio: {1}", contapezzi, retVal));
+ // invio a server contapezzi (aggiornato)
+ string retVal = utils.callUrl(urlSetPzCount + contapezzi.ToString());
+ // verifica se tutto OK
+ if (retVal != "OK")
+ {
+ // errore salvataggio contapezzi
+ lgInfo(string.Format("Errore salvataggio Contapezzi SIMULAZIONE {0} | Errore salvataggio: {1}", contapezzi, retVal));
+ }
+ // resetto timer...
+ lastPzCountSend = DateTime.Now;
}
- // resetto timer...
- lastPzCountSend = DateTime.Now;
}
}
}
diff --git a/Jenkinsfile b/Jenkinsfile
index f128ae28..1d935d66 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -16,7 +16,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
- withEnv(['NEXT_BUILD_NUMBER=332']) {
+ withEnv(['NEXT_BUILD_NUMBER=333']) {
// env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'