Correzione decodifica bitmap NWSE

- prende dati correttamente
- costruisce stringa corretta
This commit is contained in:
S.E.Locatelli
2022-06-27 10:52:20 +02:00
parent 64bf154f19
commit e2f248f57c
3 changed files with 17 additions and 16 deletions
+8 -8
View File
@@ -14,7 +14,7 @@
"name": "StatoOsmosi",
"description": "Stato Osmosi Inversa",
"memAddr": "DB100.DBB20",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 20,
"size": 2,
"func": "MAX",
@@ -28,7 +28,7 @@
"name": "StatoDepurazione",
"description": "Stato Depurazione",
"memAddr": "DB100.DBB22",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 22,
"size": 2,
"func": "MAX",
@@ -43,7 +43,7 @@
"name": "StatoFiltro01",
"description": "Stato Filtro 1",
"memAddr": "DB100.DBB24",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 24,
"size": 2,
"func": "MAX",
@@ -62,7 +62,7 @@
"name": "StatoFiltro02",
"description": "Stato Filtro 2",
"memAddr": "DB100.DBB26",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 26,
"size": 2,
"func": "MAX",
@@ -81,7 +81,7 @@
"name": "StatoFiltro03",
"description": "Stato Filtro 3",
"memAddr": "DB100.DBB28",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 28,
"size": 2,
"func": "MAX",
@@ -100,7 +100,7 @@
"name": "StatoFiltro04",
"description": "Stato Filtro 4",
"memAddr": "DB100.DBB30",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 30,
"size": 2,
"func": "MAX",
@@ -119,7 +119,7 @@
"name": "StatoFiltro05",
"description": "Stato Filtro 5",
"memAddr": "DB100.DBB32",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 32,
"size": 2,
"func": "MAX",
@@ -138,7 +138,7 @@
"name": "StatoFiltro06",
"description": "Stato Filtro 6",
"memAddr": "DB100.DBB34",
"tipoMem": "Int",
"tipoMem": "BitMap",
"index": 34,
"size": 2,
"func": "MAX",
+7 -6
View File
@@ -1885,27 +1885,28 @@ namespace IOB_WIN_NEXT
/// Effettua conversione da valore bitmap ai valori configurati
/// </summary>
/// <param name="memConf"></param>
/// <param name="bitMapVal"></param>
/// <param name="bState"></param>
/// <returns></returns>
public string getBitmapState(dataConfTSVC memConf, int bitMapVal)
public string getBitmapState(dataConfTSVC memConf, byte[] bState)
{
string valTransl = "";
List<string> descAttivi = new List<string>();
BitArray bitAttivi = new BitArray(bitMapVal);
BitArray bitAttivi = new BitArray(bState);
bool[] bitStati = new bool[bitAttivi.Count];
bitAttivi.CopyTo(bitStati, 0);
// cerco bit attivi
int idx = 0;
foreach (var item in bitStati)
{
if (item)
if (item && memConf.decodeMap.Count > idx)
{
string currState = memConf.decodeMap.Count >= idx ? memConf.decodeMap[idx] : $"State_{idx}";
string currState = memConf.decodeMap[idx];
descAttivi.Add(currState);
}
idx++;
}
// combino string
string.Join(",", descAttivi);
valTransl= string.Join(",", descAttivi);
return valTransl;
}
+2 -2
View File
@@ -848,9 +848,9 @@ namespace IOB_WIN_NEXT
break;
case plcDataType.BitMap:
valore = ((double)S7.Net.Types.Int.FromByteArray(RawInput.Skip(item.Value.index).Take(item.Value.size).ToArray())) / item.Value.factor;
byte[] byteState = RawInput.Skip(item.Value.index).Take(item.Value.size).ToArray();
// calcolo valore string come unione delle bitmap attive...
valString = getBitmapState(item.Value, (int)valore);
valString = getBitmapState(item.Value, byteState);
saveValueString(ref outVal, valString, item.Key);
break;