Cambio naming variabili SIM

This commit is contained in:
Samuele E. Locatelli
2019-01-10 13:47:56 +01:00
parent 7e8a757775
commit 069e509ce7
5 changed files with 57 additions and 60 deletions
+5 -5
View File
@@ -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
+8 -3
View File
@@ -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
+7 -2
View File
@@ -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
+7 -2
View File
@@ -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
+30 -48
View File
@@ -27,7 +27,11 @@ namespace IOB_WIN
/// <summary>
/// periodo base del simulatore (in secondi)
/// </summary>
protected int periodoSec = 1;
protected int periodoMSec = 1000;
/// <summary>
/// Parametri simulazione oscillazione bit 2
/// </summary>
protected simPar bit2;
/// <summary>
/// Parametri simulazione oscillazione bit 3
/// </summary>
@@ -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");
}
}
/// <summary>
@@ -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
/// </summary>
public override void processContapezzi()
{
if (utils.CRB("enableContapezzi"))
{
if (lastPzCountSend.AddMilliseconds(pzCountDelay) < DateTime.Now)
{
// faccio incremento x 1 pz
lastCountCNC++;
lastPzCountSend = DateTime.Now;
}
}
}
/// <summary>
/// lettura bit semafori
@@ -134,9 +134,10 @@ namespace IOB_WIN
/// </summary>
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;