Affinamento SIM x livello (descending + lento) + prog name

This commit is contained in:
Samuele Locatelli
2021-10-01 16:18:41 +02:00
parent d67da4707f
commit 22c2c3d884
3 changed files with 37 additions and 12 deletions
+1 -1
View File
@@ -39,7 +39,7 @@
<!--gestione coda-->
<add key="maxQueueFLog" value="16384" />
<!--parametri SIM-->
<add key="waitSimPar" value="5" />
<add key="waitSimPar" value="30" />
<!--<add key="waitSimPar" value="45" />-->
<!--gestione REDIS-->
<add key="RedisConn" value="localhost,abortConnect=false,ssl=false" />
+2 -2
View File
@@ -39,8 +39,8 @@
"description": "Livello Serbatoio",
"tipoMem": "Real",
"minVal": 5000,
"maxVal": 250000,
"factor": 1
"maxVal": 25000,
"factor": 5
},
"PressBH": {
"name": "SIM_PressBH",
+34 -9
View File
@@ -672,17 +672,42 @@ namespace IOB_WIN_NEXT
{
foreach (var item in memMap.mMapRead)
{
if (item.Value.factor == 1)
// se il TIPO di valore è livello --> simulo variazione da MAX --> min, con un delta in CALO pari a factor * (80-120)%
if (item.Value.name == "SIM_LEVEL")
{
// uso factor come valore MAX ammesso
int randVal = rnd.Next(item.Value.minVal, item.Value.maxVal);
outVal.Add(item.Key, randVal.ToString());
// verifico last value
float lastVal = 0;
float.TryParse(item.Value.value, out lastVal);
if (lastVal == 0)
{
lastVal = item.Value.maxVal - item.Value.factor;
}
// decremento casuale...
float newVal = lastVal - ((float)item.Value.factor * rnd.Next(80, 120) / 100);
// se inferiore a minimo --> massimo!
if (newVal < item.Value.minVal)
{
newVal = item.Value.maxVal;
}
// salvo il suo VALUE...
item.Value.value = $"{newVal}";
outVal.Add(item.Key, $"{newVal}");
}
// altrimenti siulazione random walk...
else
{
// uso factor come fattore di divisione x simulare decimali
float randVal = ((float)rnd.Next(item.Value.minVal, item.Value.maxVal)) / item.Value.factor;
outVal.Add(item.Key, randVal.ToString());
if (item.Value.factor == 1)
{
// uso factor come valore MAX ammesso
int randVal = rnd.Next(item.Value.minVal, item.Value.maxVal);
outVal.Add(item.Key, randVal.ToString());
}
else
{
// uso factor come fattore di divisione x simulare decimali
float randVal = ((float)rnd.Next(item.Value.minVal, item.Value.maxVal)) / item.Value.factor;
outVal.Add(item.Key, randVal.ToString());
}
}
}
}
@@ -700,8 +725,8 @@ namespace IOB_WIN_NEXT
/// <returns></returns>
public override string getPrgName()
{
// valore non presente in vers default... se gestito fare override
string prgName = string.Format("DEMO_{0:00}", DateTime.Now.Minute);
// NOME DEL SIM!
string prgName = $"PROG_{cIobConf.codIOB}";
return prgName;
}