diff --git a/IOB-WIN/DATA/CONF/SIMUL_01.ini b/IOB-WIN/DATA/CONF/SIMUL_01.ini
index 2209bd80..97f201e2 100644
--- a/IOB-WIN/DATA/CONF/SIMUL_01.ini
+++ b/IOB-WIN/DATA/CONF/SIMUL_01.ini
@@ -30,11 +30,11 @@ BLINK_FILT=0
[OPTPAR]
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
PZCOUNT_MODE=BIT
-; per il simulatore: 50|1 = WAIT 50, DURATION 1 con riferimento al PERIODO base (PER_BASE, default 1 secondo)
-PER_BASE=1
-SIM_BIT2=10|1
-SIM_BIT3=100|2
-SIM_BIT4=25|2
+; per il simulatore: 50|1 = WAIT 50, DURATION 1 con riferimento al PERIODO base (PER_BASE in ms, default 1 secondo)
+PER_BASE=600
+SIM_PZCNT=5|1
+SIM_ALARM=100|2
+SIM_MANU=25|2
[BRANCH]
NAME=master
\ No newline at end of file
diff --git a/IOB-WIN/DATA/CONF/SIMUL_02.ini b/IOB-WIN/DATA/CONF/SIMUL_02.ini
index 2b12f1a9..9b119452 100644
--- a/IOB-WIN/DATA/CONF/SIMUL_02.ini
+++ b/IOB-WIN/DATA/CONF/SIMUL_02.ini
@@ -21,15 +21,20 @@ CMDENABLED=/IOB/enabled/
CMDADV1=?valore=
CMDREBO=/sendReboot.aspx?idxMacchina=
-[MEMORY]
+[MEMORY]
[BLINK]
MAX_COUNTER_BLINK = 15
BLINK_FILT=0
[OPTPAR]
-;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
-PZCOUNT_MODE=BIT
+;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
+PZCOUNT_MODE=BIT
+; per il simulatore: 50|1 = WAIT 50, DURATION 1 con riferimento al PERIODO base (PER_BASE in ms, default 1 secondo)
+PER_BASE=1500
+SIM_PZCNT=8|1
+SIM_ALARM=100|4
+SIM_MANU=50|3
[BRANCH]
NAME=master
\ No newline at end of file
diff --git a/IOB-WIN/DATA/CONF/SIMUL_03.ini b/IOB-WIN/DATA/CONF/SIMUL_03.ini
index e4d880d8..f9d0ff7c 100644
--- a/IOB-WIN/DATA/CONF/SIMUL_03.ini
+++ b/IOB-WIN/DATA/CONF/SIMUL_03.ini
@@ -21,15 +21,20 @@ CMDENABLED=/IOB/enabled/
CMDADV1=?valore=
CMDREBO=/sendReboot.aspx?idxMacchina=
-[MEMORY]
+[MEMORY]
[BLINK]
MAX_COUNTER_BLINK = 15
BLINK_FILT=0
[OPTPAR]
-;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
+;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
PZCOUNT_MODE=BIT
+; per il simulatore: 50|1 = WAIT 50, DURATION 1 con riferimento al PERIODO base (PER_BASE, default 1 secondo)
+PER_BASE=2050
+SIM_PZCNT=15|1
+SIM_ALARM=100|2
+SIM_MANU=25|2
[BRANCH]
NAME=master
\ No newline at end of file
diff --git a/IOB-WIN/DATA/CONF/SIMUL_04.ini b/IOB-WIN/DATA/CONF/SIMUL_04.ini
index e4d880d8..bd58c015 100644
--- a/IOB-WIN/DATA/CONF/SIMUL_04.ini
+++ b/IOB-WIN/DATA/CONF/SIMUL_04.ini
@@ -21,15 +21,20 @@ CMDENABLED=/IOB/enabled/
CMDADV1=?valore=
CMDREBO=/sendReboot.aspx?idxMacchina=
-[MEMORY]
+[MEMORY]
[BLINK]
MAX_COUNTER_BLINK = 15
BLINK_FILT=0
[OPTPAR]
-;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
+;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
PZCOUNT_MODE=BIT
+; per il simulatore: 50|1 = WAIT 50, DURATION 1 con riferimento al PERIODO base (PER_BASE, default 1 secondo)
+PER_BASE=800
+SIM_PZCNT=11|1
+SIM_ALARM=100|2
+SIM_MANU=25|2
[BRANCH]
NAME=master
\ No newline at end of file
diff --git a/IOB-WIN/IobSimula.cs b/IOB-WIN/IobSimula.cs
index d16ed0cb..a275923c 100644
--- a/IOB-WIN/IobSimula.cs
+++ b/IOB-WIN/IobSimula.cs
@@ -27,7 +27,11 @@ namespace IOB_WIN
///
/// periodo base del simulatore (in secondi)
///
- protected int periodoSec = 1;
+ protected int periodoMSec = 1000;
+ ///
+ /// Parametri simulazione oscillazione bit 2
+ ///
+ protected simPar bit2;
///
/// Parametri simulazione oscillazione bit 3
///
@@ -57,10 +61,15 @@ namespace IOB_WIN
{
if (cIobConf.optPar["PER_BASE"] != "")
{
- int.TryParse(cIobConf.optPar["PER_BASE"], out periodoSec);
+ int.TryParse(cIobConf.optPar["PER_BASE"], out periodoMSec);
+ // aggiungo NOISE... +/- 20%
+ Random rnd = new Random();
+ int noise = rnd.Next(1, periodoMSec / 5);
+ periodoMSec += noise - (periodoMSec / 10);
}
- bit3 = setupSimPar("SIM_BIT3");
- bit4 = setupSimPar("SIM_BIT4");
+ bit2 = setupSimPar("SIM_PZCNT");
+ bit3 = setupSimPar("SIM_ALARM");
+ bit4 = setupSimPar("SIM_MANU");
}
}
///
@@ -80,10 +89,10 @@ namespace IOB_WIN
string[] param = fullVal.Split('|');
int.TryParse(param[0], out answ.wait);
int.TryParse(param[1], out answ.duration);
- // aggiongo disturbo...
+ // aggiongo noise, +/- 20%...
Random rnd = new Random();
- int noise = rnd.Next(1, answ.wait / 10);
- answ.wait += noise;
+ int noise = rnd.Next(1, answ.wait / 5);
+ answ.wait += noise - (answ.wait / 10);
}
}
}
@@ -109,15 +118,6 @@ namespace IOB_WIN
///
public override void processContapezzi()
{
- if (utils.CRB("enableContapezzi"))
- {
- if (lastPzCountSend.AddMilliseconds(pzCountDelay) < DateTime.Now)
- {
- // faccio incremento x 1 pz
- lastCountCNC++;
- lastPzCountSend = DateTime.Now;
- }
- }
}
///
/// lettura bit semafori
@@ -134,9 +134,10 @@ namespace IOB_WIN
///
public override void processVHF()
{
- if (lastEvCheck.AddSeconds(periodoSec) < DateTime.Now)
+ if (lastEvCheck.AddMilliseconds(periodoMSec) < DateTime.Now)
{
// decremento contatore ultimo evento
+ bit2.wait--;
bit3.wait--;
bit4.wait--;
lastEvCheck = DateTime.Now;
@@ -171,7 +172,7 @@ namespace IOB_WIN
// controllo se sia scaduta la duration... in quel caso reset...
if (bit3.duration <= 0)
{
- bit3 = setupSimPar("SIM_BIT3");
+ bit3 = setupSimPar("SIM_ALARM");
}
}
else if (bit4.wait <= 0)
@@ -183,54 +184,35 @@ namespace IOB_WIN
// controllo se sia scaduta la duration... in quel caso reset...
if (bit4.duration <= 0)
{
- bit4 = setupSimPar("SIM_BIT4");
+ bit4 = setupSimPar("SIM_MANU");
}
}
-
-#if false
- // ogni periodo_sec x 2 invio un segnale allarme = B3
- if ((DateTime.Now.Second % (periodoSec * 2)) == 0)
+ else if (bit2.wait <= 0)
{
- B_input = 9;
- }
- // ogni periodo_sec invio un segnale manuale = B4
- else if ((DateTime.Now.Second % periodoSec) == 0)
- {
- B_input = 17;
- }
-#endif
- // CONTROLLO INVIO SOLO SE รจ in stato "3"...
- if (B_input == 3)
- {
-
bool sendContapezzi = false;
- // se sono differenti MOSTRO...
- if (lastCountCNC != contapezzi)
- {
- // registro contapezzi
- lgInfo(string.Format("Differenza Contapezzi: READ: {0} | Interno {1}", lastCountCNC, contapezzi));
- }
- // verifico se variato contapezzi... e se passato ritardo minimo...
- if (lastCountCNC > contapezzi)
+ // segnalo BIT
+ B_input += (1 << 2);
+ // decremento duration
+ bit2.duration--;
+ // controllo se sia scaduta la duration... in quel caso reset...
+ if (bit2.duration <= 0)
{
+ bit2 = setupSimPar("SIM_MANU");
// salvo nuovo contapezzi (incremento di 1...)
contapezzi++;
sendContapezzi = true;
- // salvo in semaforo!
- B_input += (1 << 2);
// registro contapezzi
- lgInfo(string.Format("Contapezzi SIMULAZIONE: {0} | Contapezzi interno {1}", lastCountCNC, contapezzi));
+ lgInfo(string.Format("Contapezzi SIMULAZIONE: {0}", contapezzi));
}
if (sendContapezzi)
{
-
// 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} | Contapezzi interno {1} | Errore salvataggio: {2}", lastCountCNC, contapezzi, retVal));
+ lgInfo(string.Format("Errore salvataggio Contapezzi SIMULAZIONE {0} | Errore salvataggio: {1}", contapezzi, retVal));
}
// resetto timer...
lastPzCountSend = DateTime.Now;