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:
50
Dabit.Mcp/Tools/TimeTools.cs
Normal file
50
Dabit.Mcp/Tools/TimeTools.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.ComponentModel;
|
||||
using Dabit.Mcp.Services;
|
||||
using DibdProtocol.Protocol;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
namespace Dabit.Mcp.Tools;
|
||||
|
||||
/// <summary>컨트롤러 시각 동기화 도구. ⚠️ 쓰기.</summary>
|
||||
[McpServerToolType]
|
||||
public sealed class TimeTools
|
||||
{
|
||||
private readonly LedControlService _led;
|
||||
private readonly ILogger<TimeTools> _log;
|
||||
|
||||
public TimeTools(LedControlService led, ILogger<TimeTools> log)
|
||||
{
|
||||
_led = led;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
// 정본 SettingsViewModel: ToBcd(v) = (v/10*16)+(v%10). 26 → 0x26.
|
||||
private static byte ToBcd(int v) => (byte)(v / 10 * 16 + v % 10);
|
||||
|
||||
private static string KoreanDow(DayOfWeek d) => d switch
|
||||
{
|
||||
DayOfWeek.Sunday => "일", DayOfWeek.Monday => "월", DayOfWeek.Tuesday => "화",
|
||||
DayOfWeek.Wednesday => "수", DayOfWeek.Thursday => "목", DayOfWeek.Friday => "금",
|
||||
_ => "토",
|
||||
};
|
||||
|
||||
[McpServerTool]
|
||||
[Description("컨트롤러의 시각(RTC)을 현재 PC 시간으로 동기화한다. ⚠️ 쓰기·설정 저장.")]
|
||||
public async Task<string> SyncControllerTime(CancellationToken ct = default)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
// 정본 0x47: [yy(BCD), MM(BCD), dd(BCD), dow(raw 0=일~6=토), HH(BCD), mm(BCD), ss(BCD)]
|
||||
byte[] payload =
|
||||
{
|
||||
ToBcd(now.Year % 100), ToBcd(now.Month), ToBcd(now.Day),
|
||||
(byte)(int)now.DayOfWeek,
|
||||
ToBcd(now.Hour), ToBcd(now.Minute), ToBcd(now.Second),
|
||||
};
|
||||
var resp = await _led.SendHexAsync(HexCommand.SyncTime, payload, ct, 5000);
|
||||
var (ok, msg) = LedControlService.CheckWriteStatus(HexCommand.SyncTime, resp);
|
||||
return ok
|
||||
? $"시간 동기화 완료: {now:yyyy-MM-dd HH:mm:ss} ({KoreanDow(now.DayOfWeek)})."
|
||||
: $"시간 동기화 실패 — {msg}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user