Torna al Thread

public delegate void Aggiorna(string argValue); private void _Leggi() { while (true) { sp.Write (">erFF??!"); byte[] ByteLetti = new byte[1]; if (sp.BytesToRead > 0) { Array.Resize(ref ByteLetti, sp.BytesToRead); sp.Read(ByteLetti, 0, ByteLetti.Length); s_ricevi = System.Text.Encoding.ASCII.GetString(ByteLetti); this.Invoke(new Aggiorna(_Aggiorna), s_ricevi); } if (l == 21) { this.Invoke(new Aggiorna(stato), s_ricevi); } // Calcolo valore uscite digitali (in esadecimale) try { hex = string.Concat(DO8, DO7, DO6, DO5, DO4, DO3, DO2, DO1); ODhex = String.Format("{0:X2}", Convert.ToInt32(hex, 2)); } catch { } // Calcolo protocollo di scrittura protscritt1 = protscritt; protscritt = string.Concat(">", indasc, "w", "FF", "00", "00", ODhex, CheckSum(">" + indasc + "w" + "FF" + "00" + "00" + ODhex), "!"); Thread.Sleep(100); if (protscritt != protscritt1) { sp.Write(protscritt); // stringa comando periferica } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5