feat(mcp): Dabit.Mcp 초기 공개 (리네임 + colors 수정 + scroll 검증)
- refactor: DabitChe.Mcp → Dabit.Mcp (namespace, csproj, exe 모두) - fix: display_message colors를 쉼표 구분 문자열로 변경 (ModelContextProtocol 1.3.0 배열 바인딩 버그 우회) - docs: scroll 4방향(left/right/up/down) 실기 검증 완료 (DIBD600T V3.6.1) 20 도구 (읽기 4 + 콘텐츠 2 + 설정 14), stdio 전송, Windows exe. 실기 검증: scroll/fill_screen 8색/display_message 글자별색 모두 정상. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
54
Dabit.Mcp/Tools/BoardTools.cs
Normal file
54
Dabit.Mcp/Tools/BoardTools.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.ComponentModel;
|
||||
using Dabit.Mcp.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
namespace Dabit.Mcp.Tools;
|
||||
|
||||
/// <summary>보드기능설정 읽기/저장 도구(디버그·포트기능·통신속도). ⚠️ 저장은 쓰기.</summary>
|
||||
[McpServerToolType]
|
||||
public sealed class BoardTools
|
||||
{
|
||||
private readonly LedControlService _led;
|
||||
private readonly ILogger<BoardTools> _log;
|
||||
|
||||
public BoardTools(LedControlService led, ILogger<BoardTools> log)
|
||||
{
|
||||
_led = led;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
[McpServerTool]
|
||||
[Description("보드기능설정을 읽는다(디버그/BH1·J4 기능/J2·J3·BH1 통신속도 인덱스). 읽기 — 표시 변경 없음.")]
|
||||
public async Task<string> ReadBoardSettings(CancellationToken ct = default)
|
||||
{
|
||||
var resp = await _led.SendAsciiAsync("B3", "0", ct, 5000);
|
||||
if (resp is null)
|
||||
return "보드설정 읽기 실패 — 연결 또는 통신 오류.";
|
||||
var f = resp.Data.Trim().Split(',');
|
||||
if (f.Length < 6)
|
||||
return $"보드설정 응답 형식이 예상과 다릅니다: \"{resp.Data}\"";
|
||||
var rs = f.Length >= 7 ? $", RS485주소={f[6]}" : "";
|
||||
return $"보드설정 — debug={f[0]}, BH1기능={f[1]}, J4기능={f[2]}, J2속도={f[3]}, J3속도={f[4]}, BH1속도={f[5]}{rs}";
|
||||
}
|
||||
|
||||
[McpServerTool]
|
||||
[Description("보드기능설정을 저장한다. ⚠️ 쓰기·설정 저장. 범위: debug 0~15, 나머지 0~7. 잘못 설정하면 통신이 끊길 수 있으니 주의.")]
|
||||
public async Task<string> SaveBoardSettings(
|
||||
[Description("디버그 레벨 0~15")] int debug,
|
||||
[Description("BH1 포트 기능 0~7")] int bh1Func,
|
||||
[Description("J4 포트 기능 0~7")] int j4Func,
|
||||
[Description("J2 통신속도 인덱스 0~7")] int j2Baud,
|
||||
[Description("J3 통신속도 인덱스 0~7")] int j3Baud,
|
||||
[Description("BH1 통신속도 인덱스 0~7")] int bh1Baud,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
// 정본 B2: data 맨 앞 공백 1개 + 6필드. debug만 HEX 대문자, 나머지 10진수.
|
||||
var hexDebug = Math.Clamp(debug, 0, 15).ToString("X");
|
||||
var data = $" {hexDebug},{Math.Clamp(bh1Func, 0, 7)},{Math.Clamp(j4Func, 0, 7)},{Math.Clamp(j2Baud, 0, 7)},{Math.Clamp(j3Baud, 0, 7)},{Math.Clamp(bh1Baud, 0, 7)}";
|
||||
var resp = await _led.SendAsciiAsync("B2", data, ct, 5000);
|
||||
if (resp is null)
|
||||
return "보드설정 저장 실패 — 연결 또는 통신 오류.";
|
||||
return resp.Result == "F" ? "전광판이 거부했습니다 (Result=F)." : "보드설정 저장 완료.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user