diff --git a/IOB-WIN-NEXT/App.config b/IOB-WIN-NEXT/App.config index 6b3846da..e98ffce7 100644 --- a/IOB-WIN-NEXT/App.config +++ b/IOB-WIN-NEXT/App.config @@ -39,7 +39,7 @@ - + diff --git a/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json b/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json index 9534a73f..c929fe76 100644 --- a/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json +++ b/IOB-WIN-NEXT/DATA/CONF/SIM_PIZ00.json @@ -39,8 +39,8 @@ "description": "Livello Serbatoio", "tipoMem": "Real", "minVal": 5000, - "maxVal": 250000, - "factor": 1 + "maxVal": 25000, + "factor": 5 }, "PressBH": { "name": "SIM_PressBH", diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 8d771f5f..41968dad 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -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 /// 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; }