public override void VisitCodeBlock(CodeBlock codeBlock) { Write($"#label_{codeBlock.Definition.Id}:"); WriteLine(); Indent(); foreach (var instruction in codeBlock.Instructions) { Visit(instruction); } if (codeBlock.UnrecognizedBytes.Length > 0) { var bytes = codeBlock.UnrecognizedBytes.ToArray(); string unrecognizedPart = BinaryUtils.BytesToHexString(bytes, " "); WriteLine(); Write("#unrecognized:"); WriteLine(); Write(unrecognizedPart); } Outdent(); WriteLine(); }
private SC3Game IdentifySC3Game(byte[] headerBytes) { string strHeader = BinaryUtils.BytesToHexString(headerBytes); var supportedGames = GameSpecificData.SupportedGames; return(supportedGames.Single(game => GameSpecificData.For(game).SupportedModules.Contains(strHeader))); }
private async void HandleClientAsync(TcpClient client, CancellationToken token) // async void - avoid, надо сделать шт { ApplicationCore.GetInstance().GetLogger().LogDebug($"Handle input connection from {client.Client.RemoteEndPoint.ToString()}"); var stream = client.GetStream(); byte[] buffer = new byte[256]; int readCount; try { while ((readCount = await stream.ReadAsync(buffer, 0, buffer.Length, token)) != 0) { ApplicationCore.GetInstance().GetLogger().LogInfo($"New data received from {client.Client.RemoteEndPoint.ToString()}"); ApplicationCore.GetInstance().GetLogger().LogInfo($"<-: {BinaryUtils.BytesToHexString(buffer, 0, readCount)}"); foreach (var module in modules) { var data = new byte[readCount]; Array.Copy(buffer, 0, data, 0, data.Length); if (module.IsPackageBelongsToModule(data)) { if (module.HasCorrectPackage(data)) { ApplicationCore.GetInstance().GetLogger().LogInfo($"{module.GetSerial()} handling data..."); module.HandleData(data); } } } } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.ToString()); } finally { client.Close(); } }
public override void VisitSetColorCommand(SetColorCommand setColorCommand) { string index = BinaryUtils.BytesToHexString(setColorCommand.ColorIndex.Bytes); _writer.Write($"[color index=\"{index}\"]"); }