|
|
|
@@ -10,6 +10,9 @@ public class PepTools
|
|
|
|
|
BaseAddress = new Uri("http://localhost:8085")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static string LaserQuoteBaseUrl { get; set; } = "http://localhost:5260";
|
|
|
|
|
private static readonly HttpClient _laserQuoteClient = new();
|
|
|
|
|
|
|
|
|
|
private static readonly JsonSerializerOptions _jsonOptions = new()
|
|
|
|
|
{
|
|
|
|
|
PropertyNameCaseInsensitive = true,
|
|
|
|
@@ -571,4 +574,48 @@ public class PepTools
|
|
|
|
|
return $"Error calling PEP API: {ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[McpServerTool, Description("Compare the geometry of a part between PEP (nesting software) and LaserQuote (quoting software). Returns bounding box dimensions, cut length, entity counts, pixel diff %, and alignment strategy. Use this to detect when part drawings have drifted between systems.")]
|
|
|
|
|
public static async Task<string> CompareGeometry(
|
|
|
|
|
[Description("The part number to compare (e.g., 'SULLYS-003')")] string partNumber)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var url = $"{LaserQuoteBaseUrl}/api/geometry/compare?partNumber={Uri.EscapeDataString(partNumber)}";
|
|
|
|
|
var response = await _laserQuoteClient.GetAsync(url);
|
|
|
|
|
var json = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
var result = System.Text.Json.JsonSerializer.Deserialize<GeometryCompareResult>(json, _jsonOptions);
|
|
|
|
|
|
|
|
|
|
if (result?.Error != null)
|
|
|
|
|
return $"Note: {result.Error}";
|
|
|
|
|
|
|
|
|
|
var sb = new System.Text.StringBuilder();
|
|
|
|
|
sb.AppendLine($"Geometry Comparison: {partNumber}");
|
|
|
|
|
sb.AppendLine($"Result: {(result?.IsMatch == true ? "MATCH ✓" : "MISMATCH ✗")}");
|
|
|
|
|
sb.AppendLine($"Pixel Diff: {result?.PixelDiffPercent:F3}%");
|
|
|
|
|
sb.AppendLine($"Alignment: {result?.AlignmentLabel}");
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
sb.AppendLine("| Metric | LaserQuote | PEP |");
|
|
|
|
|
sb.AppendLine("|---------------|-----------------|-----------------|");
|
|
|
|
|
sb.AppendLine($"| Width (in) | {result?.LaserQuote?.Width,15:F4} | {result?.Pep?.Width,15:F4} |");
|
|
|
|
|
sb.AppendLine($"| Height (in) | {result?.LaserQuote?.Height,15:F4} | {result?.Pep?.Height,15:F4} |");
|
|
|
|
|
sb.AppendLine($"| Cut Length | {result?.LaserQuote?.CutLength,15:F3} | {result?.Pep?.CutLength,15:F3} |");
|
|
|
|
|
sb.AppendLine($"| Entity Count | {result?.LaserQuote?.EntityCount,15} | {result?.Pep?.EntityCount,15} |");
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return $"Error calling LaserQuote API: {ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private record GeometryMetricDto(double Width, double Height, double CutLength, int EntityCount);
|
|
|
|
|
private record GeometryCompareResult(
|
|
|
|
|
bool IsMatch,
|
|
|
|
|
GeometryMetricDto? LaserQuote,
|
|
|
|
|
GeometryMetricDto? Pep,
|
|
|
|
|
double PixelDiffPercent,
|
|
|
|
|
string? AlignmentLabel,
|
|
|
|
|
string? Error);
|
|
|
|
|
}
|
|
|
|
|