a502322188
손상된 .git 히스토리(missing tree)로 재초기화 후 작업트리 전체 커밋. .claude/ 만 제외(로컬 에이전트 설정). 구 저장소 백업(.git_corrupt_backup/) 포함. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
102 lines
4.5 KiB
C#
102 lines
4.5 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
|
|
namespace RJ2RoomConSimulator
|
|
{
|
|
// VSP(테스트 모드) 프리셋 조회/설정 팝업.
|
|
// select 코드(펌웨어 My_RJ2.c) : 1~4 환기1~4 / 5 바이패스 / 6~9 공청1~4 (공청은 EA 미사용)
|
|
public partial class VspWindow : Window
|
|
{
|
|
readonly RoomConProtocol _proto;
|
|
|
|
// 프리셋 행 정의 : (select, 라벨, EA 사용여부)
|
|
static readonly (byte sel, string label, bool hasEa)[] Defs =
|
|
{
|
|
(1,"환기 1단",true),(2,"환기 2단",true),(3,"환기 3단",true),(4,"환기 4단",true),
|
|
(5,"바이패스",true),
|
|
(6,"공청 1단",false),(7,"공청 2단",false),(8,"공청 3단",false),(9,"공청 4단",false),
|
|
};
|
|
readonly TextBox[] _sa = new TextBox[10]; // index = select
|
|
readonly TextBox[] _ea = new TextBox[10];
|
|
|
|
static Brush Br(string h) => (Brush)new BrushConverter().ConvertFromString(h)!;
|
|
static readonly Brush CardBg = Br("#313147");
|
|
static readonly Brush Border = Br("#3B3B55");
|
|
static readonly Brush TextPri = Br("#C0CAF5");
|
|
|
|
public VspWindow(RoomConProtocol proto)
|
|
{
|
|
InitializeComponent();
|
|
_proto = proto;
|
|
BuildRows();
|
|
_proto.ResponseReceived += OnResponse;
|
|
Closed += (_, _) => _proto.ResponseReceived -= OnResponse;
|
|
}
|
|
|
|
void BuildRows()
|
|
{
|
|
foreach (var d in Defs)
|
|
{
|
|
var g = new Grid { Margin = new Thickness(0, 2, 0, 2) };
|
|
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(90) });
|
|
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(70) });
|
|
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(70) });
|
|
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(70) });
|
|
|
|
var lab = new TextBlock { Text = d.label, FontSize = 12, Foreground = TextPri, VerticalAlignment = VerticalAlignment.Center };
|
|
Grid.SetColumn(lab, 0); g.Children.Add(lab);
|
|
|
|
var sa = MakeBox(); Grid.SetColumn(sa, 1); g.Children.Add(sa); _sa[d.sel] = sa;
|
|
var ea = MakeBox(); ea.IsEnabled = d.hasEa; Grid.SetColumn(ea, 2); g.Children.Add(ea); _ea[d.sel] = ea;
|
|
|
|
byte sel = d.sel;
|
|
var btn = new Button { Content = "설정", Padding = new Thickness(10, 3, 10, 3), FontSize = 11, Margin = new Thickness(4, 0, 0, 0),
|
|
Style = (Style)FindResource("ModernButton"), Background = CardBg };
|
|
btn.Click += (_, _) => SetRow(sel);
|
|
Grid.SetColumn(btn, 3); g.Children.Add(btn);
|
|
|
|
RowsPanel.Children.Add(g);
|
|
}
|
|
}
|
|
|
|
TextBox MakeBox() => new()
|
|
{
|
|
Width = 60, Margin = new Thickness(2, 0, 2, 0), Padding = new Thickness(3, 2, 3, 2),
|
|
TextAlignment = TextAlignment.Center, FontSize = 12, Text = "0",
|
|
Background = CardBg, Foreground = TextPri, BorderBrush = Border, BorderThickness = new Thickness(1),
|
|
};
|
|
|
|
void SetRow(byte sel)
|
|
{
|
|
byte sa = ParseByte(_sa[sel].Text);
|
|
byte ea = _ea[sel].IsEnabled ? ParseByte(_ea[sel].Text) : (byte)0;
|
|
_proto.SendVsp(sel, sa, ea);
|
|
}
|
|
static byte ParseByte(string s) { int.TryParse(s, out var v); return (byte)(v < 0 ? 0 : v > 255 ? 255 : v); }
|
|
|
|
void QueryVent_Click(object s, RoutedEventArgs e) => _proto.SendRestart1();
|
|
void QueryBypassAir_Click(object s, RoutedEventArgs e) => _proto.SendRestart2();
|
|
void Exit_Click(object s, RoutedEventArgs e) => _proto.SendExit();
|
|
void Close_Click(object s, RoutedEventArgs e) => Close();
|
|
|
|
// 조회 응답 수신 → 표 갱신
|
|
void OnResponse(byte cmd)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
if (cmd == RoomConProtocol.CMD_RESTART1)
|
|
{
|
|
for (int i = 1; i <= 4; i++) { _sa[i].Text = _proto.VentSa[i].ToString(); _ea[i].Text = _proto.VentEa[i].ToString(); }
|
|
}
|
|
else if (cmd == RoomConProtocol.CMD_RESTART2)
|
|
{
|
|
_sa[5].Text = _proto.BypassSa[1].ToString(); _ea[5].Text = _proto.BypassEa[1].ToString();
|
|
for (int i = 1; i <= 4; i++) { _sa[5 + i].Text = _proto.AirSa[i].ToString(); _ea[5 + i].Text = "0"; }
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|