public async Task PollTest() { while (true) { InverterData.Read.command = "QMOD"; PopulateData("(BçÉ"); InverterData.Read.command = "QPIRI"; PopulateData("(230.0 21.7 230.0 50.0 21.7 5000 5000 48.0 51.0 48.0 55.0 54.4 2 50 050 0 2 3 1 01 0 0 52.0 0 1 "); // x.PopulateData("(230.0 21.7 230.0 50.0 21.7 5000 5000 48.0 51.0 48.0 55.0 54.4 2 50 050 0 2 3 1 01 0 0 52.0 0 1?"); InverterData.Read.command = "QPIGS"; PopulateData("(244.8 50.0 229.8 49.9 0824 0824 016 355 51.70 000 035 0020 00.0 000.0 00.00 00019 00010000 00 00 00000 010<"); //x.PopulateData("(240.8 49.9 230.2 50.0 0368 0289 007 394 52.40 000 042 0038 00.7 364.3 00.00 00000 00010110 00 00 00290 010ª4"); InverterData.Read.command = "QPIWS"; PopulateData("(000000000000000000000000000000000000<?"); Task.Run(() => ManagedClientTest.RunAsync1("values")); await Task.Delay(10000); } }
public void ProcessRead() { try { byte[] data = InverterData.Read.data; StringBuilder sb = new StringBuilder(data.Length * 2); foreach (byte b in data) { sb.Append(Convert.ToString(b, 16).PadLeft(2, '0')); } string hexString = sb.ToString(); string ascii = string.Empty; for (int i = 0; i < hexString.Length; i += 2) { String hs = string.Empty; hs = hexString.Substring(i, 2); uint decval = System.Convert.ToUInt32(hs, 16); char character = System.Convert.ToChar(decval); ascii += character; } PopulateData(ascii); if (InverterData.Read.command == "QPIWS") { Task.Run(() => ManagedClientTest.RunAsync1("values")); } InverterData.Read.command = ""; InverterData.Read.data = new byte[0]; Logging.DebugWrite("Debug", "CRead - " + ascii); } catch (Exception ex) { Logging.DebugWrite("Error", ex.StackTrace); } }