版本260406
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using OrpaonVision.Core.Results;
|
||||
using OrpaonVision.SiteApp.Runtime.Contracts;
|
||||
using OrpaonVision.SiteApp.Runtime.Options;
|
||||
|
||||
namespace OrpaonVision.SiteApp.Runtime.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 规则引擎简化实现(MVP 阶段)。
|
||||
/// </summary>
|
||||
public sealed class SimpleRuleEngineService : IRuleEngineService
|
||||
{
|
||||
private readonly RuntimeOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数。
|
||||
/// </summary>
|
||||
public SimpleRuleEngineService(RuntimeOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Result<RuntimeDecisionDto> Evaluate(int currentLayer, InferenceResultDto inference)
|
||||
{
|
||||
var isPass = inference.Label == "OK" || inference.Confidence < _options.NgConfidenceThreshold;
|
||||
var decision = new RuntimeDecisionDto
|
||||
{
|
||||
IsPass = isPass,
|
||||
Code = isPass ? "RULE_PASS" : "RULE_NG",
|
||||
Message = isPass
|
||||
? $"第 {currentLayer} 层判定通过。"
|
||||
: $"第 {currentLayer} 层判定 NG:{inference.Label}"
|
||||
};
|
||||
|
||||
return Result<RuntimeDecisionDto>.Success(decision, message: "规则判定完成。");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user