final receipt update

This commit is contained in:
EugeneTes
2026-01-22 11:09:38 +01:00
parent 9fbc61dede
commit fcb192b797
31 changed files with 2679 additions and 655 deletions

View File

@@ -6,62 +6,22 @@ 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<string> { "Wasabi" },
Added = new List<string> { "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<string> { "Onion" },
Added = new List<string> { "Extra Sauce" }
},
Comment = "Medium rare"
});
receipt.Gangs[0].Dishes.Add(new Dish(1, "Salmon Taco")
{
Modifications = new DishModifications
{
Added = new List<string> { "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);
var printCommands = CreateCommands(_profileT30, "Templates\\final-receipt.template", "Samples\\final-receipt.json");
Console.WriteLine("=== PRINT COMMANDS ===\n");
var printer = new HtmlPrinter(@".\test.html", paperWidth: 258);
var printer = new HtmlPrinter(@".\test.html", paperWidth: 384);
await printer.ConnectAsync("");
bool useDelay = false;
//var printer = new EpsonPrinter();
@@ -97,4 +57,17 @@ foreach (var command in printCommands)
await printer.FeedLinesAsync(5);
if (useDelay) await Task.Delay(200 * 5);
await printer.CutAsync();
await printer.CutAsync();
List<PrintCommand> CreateCommands(PrinterProfile printerProfile, string templateFile,string jsonFile)
{
var lexer = new Lexer(File.ReadAllText(templateFile));
var parser = new Parser(lexer.Tokenize().Tokens);
var template = parser.Parse().Template;
var interpreter = new TemplateInterpreter(printerProfile);
var printCommands = interpreter.Interpret(template, File.ReadAllText(jsonFile));
return printCommands;
}