Torna al Thread
class Contatori
{
public void GestioneContatori(string RigaDaGestire, char risultato, string[] Contatore, int[] ConteggioContatore, byte[] AppoggioContatori)
{
int Setpoint = int.Parse((RigaDaGestire.Substring(59, 5)));
if (risultato == '1')
{
if (AppoggioContatori[int.Parse(RigaDaGestire.Substring(48, 3))] == 0)
{
switch (RigaDaGestire.Substring(54, 1))
{
case "+" : // Incremento
ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] ++;
break;
case "-" : // Decremento
if (ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] > 0)
{
ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] --;
}
break;
case "R" : // Reset
if (risultato == '1')
{
ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] = 0;
}
break;
}
}
AppoggioContatori[int.Parse(RigaDaGestire.Substring(48, 3))] = 1;
}
else
{
AppoggioContatori[int.Parse(RigaDaGestire.Substring(48, 3))] = 0;
}
if (ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] >= Setpoint)
{
Contatore[int.Parse(RigaDaGestire.Substring(48, 3))] = "1";
ConteggioContatore[int.Parse(RigaDaGestire.Substring(48, 3))] = 0;
}
}
}