using Inspectron.Epson; using Inspectron.Epson.PrintServer.Printers.Utils; using Inspectron.Epson.PrintServer.Printers.Utils.KitchenReceipt; using Inspectron.Epson.Templates.Configuration; using Inspectron.Epson.Templates.Interpreter; using Inspectron.Epson.Templates.Language; using System.Text.Json; var receipt = new KitchenReceipt { Title = "Warme Küche", TransactionDateTime = new DateTime(2025, 10, 23, 12, 18, 0), ReceiptNumber = "132018166", WaiterName = "Mariano Amato", WaiterId = "32 (VK Restaurant)", TableNumber = "22", SpecialInstruction = "Next dish" }; // Add dishes (this section can be empty if no dishes were ordered) receipt.Gangs.Add(new Gang(2, "Gang")); receipt.Gangs[0].Dishes.Add(new Dish(1, "Avocado Sashimi") { Modifications = new DishModifications { Removed = new List { "Wasabi" }, Added = new List { "Extra Ginger" } }, Comment = "No soy sauce" }); receipt.Gangs[0].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl")); receipt.Gangs[0].Dishes.Add(new Dish(1, "Beef Tataki") { Modifications = new DishModifications { Removed = new List { "Onion" }, Added = new List { "Extra Sauce" } }, Comment = "Medium rare" }); receipt.Gangs[0].Dishes.Add(new Dish(1, "Salmon Taco") { Modifications = new DishModifications { Added = new List { "Extra Lime" } } }); // Add additional info var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true }); var lexer = new Lexer(File.ReadAllText("kitchen-u220.template")); var parser = new Parser(lexer.Tokenize().Tokens); var template = parser.Parse().Template; PrinterProfile _profileT30 = new("tm-t30iii", "TM-T30III", 48, 24, false); PrinterProfile _profile220 = new("tm-220", "TM-220", 33, 18, true); var interpreter = new TemplateInterpreter(_profile220); var printCommands = interpreter.Interpret(template, serializedReceipt); Console.WriteLine("=== PRINT COMMANDS ===\n"); var printer = new HtmlPrinter(@".\test.html", paperWidth: 258); await printer.ConnectAsync(""); bool useDelay = false; //var printer = new EpsonPrinter(); //await printer.ConnectAsync("127.0.0.1", 8888); if (useDelay) await Task.Delay(200); await printer.FeedLinesAsync(1); //await printer.SetCustomLineSpacing(22); foreach (var command in printCommands) { string attributes = ""; if (command.IsBig) attributes += "[BIG] "; if (command.IsBold) attributes += "[BOLD] "; if (command.IsRed) attributes += "[RED] "; Console.WriteLine($"{attributes}{command.Text}"); await printer.SetBiggerFontTM220(command.IsBig, command.IsTall , secondaryFont: false); if (useDelay) await Task.Delay(200); await printer.SetRedColor(command.IsRed); if (useDelay) await Task.Delay(200); await printer.SetEmphasized(command.IsBold); if (useDelay) await Task.Delay(200); await printer.PrintTextAsync(command.Text + "\n"); if (useDelay) await Task.Delay(200); } await printer.FeedLinesAsync(5); if (useDelay) await Task.Delay(200 * 5); await printer.CutAsync();