diff --git a/SmartAquaViewer/Classes/GraphSettings.cs b/SmartAquaViewer/Classes/GraphSettings.cs new file mode 100644 index 0000000..ad8546f --- /dev/null +++ b/SmartAquaViewer/Classes/GraphSettings.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static SmartAquaViewer.Model.Enums; + +namespace SmartAquaViewer.Classes +{ + public interface IChartSettings + { + GraphType Kind { get; } + } + + public sealed class AvailableFields + { + public IReadOnlyList Numeric { get; init; } = new List(); + public IReadOnlyList Categorical { get; init; } = new List(); + } + + public class LineSettings : IChartSettings + { + public GraphType Kind => GraphType.LINE; + [Required] public string XField { get; set; } = ""; // 보통 시간 + [MinLength(1)] public List YFields { get; set; } = new(); + public bool ShowLegend { get; set; } = true; + } + + public class BoxPlotSettings : IChartSettings + { + public GraphType Kind => GraphType.BOX; + [Required] public string GroupField { get; set; } = ""; // 수조/장비 등 카테고리 + [Required] public string ValueField { get; set; } = ""; // DO, pH, 압력 등 숫자 + public bool ShowOutliers { get; set; } = true; + } + + public class ScatterSettings : IChartSettings + { + public GraphType Kind => GraphType.SCATTER; + [Required] public string XField { get; set; } = ""; // 숫자 + [Required] public string YField { get; set; } = ""; // 숫자 + public string? ColorBy { get; set; } // 카테고리(수조/장비/상태) + public string? SizeBy { get; set; } // 숫자(버블 크기) + } + + public class StepSettings : IChartSettings + { + public GraphType Kind => GraphType.STEP; + [Required] public string XField { get; set; } = ""; // 보통 시간 + // 장비별 상태 필드 매핑 + public ObservableCollection Series { get; } = new(); + public double OnValue { get; set; } = 1; + public double OffValue { get; set; } = 0; + } + + public class StateSeriesMap + { + public string SeriesName { get; set; } = ""; // 예: "오존용해장치" + public string Field { get; set; } = ""; // 예: "오존용해장치(상태)" + public string OnToken { get; set; } = "ON"; + public string OffToken { get; set; } = "OFF"; + } + +} diff --git a/SmartAquaViewer/Controls/GraphControl.xaml b/SmartAquaViewer/Controls/GraphControl.xaml new file mode 100644 index 0000000..d32cf89 --- /dev/null +++ b/SmartAquaViewer/Controls/GraphControl.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SmartAquaViewer/Controls/GraphControl.xaml.cs b/SmartAquaViewer/Controls/GraphControl.xaml.cs new file mode 100644 index 0000000..d2e6cb6 --- /dev/null +++ b/SmartAquaViewer/Controls/GraphControl.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SmartAquaViewer.Controls +{ + /// + /// GraphControl.xaml에 대한 상호 작용 논리 + /// + public partial class GraphControl : UserControl + { + public GraphControl() + { + InitializeComponent(); + } + + private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } + } +} diff --git a/SmartAquaViewer/Model/Enums.cs b/SmartAquaViewer/Model/Enums.cs index 139b68e..413aaf7 100644 --- a/SmartAquaViewer/Model/Enums.cs +++ b/SmartAquaViewer/Model/Enums.cs @@ -14,5 +14,13 @@ namespace SmartAquaViewer.Model Filter, Sterilizer } + + public enum GraphType + { + LINE, + BOX, + SCATTER, + STEP + } } } diff --git a/SmartAquaViewer/ViewModel/DataGridSectionViewModel.cs b/SmartAquaViewer/ViewModel/DataGridSectionViewModel.cs deleted file mode 100644 index 1d9bf90..0000000 --- a/SmartAquaViewer/ViewModel/DataGridSectionViewModel.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using SmartAquaViewer.DataAnalysis; - -namespace SmartAquaViewer.ViewModel -{ - public interface IGridSection { string Title { get; } } - - public class TankSection : IGridSection - { - public string Title { get; set; } = "수조"; - public ObservableCollection Rows { get; } = new(); - } - public class FilterSection : IGridSection - { - public string Title { get; set; } = "여과"; - public ObservableCollection Rows { get; } = new(); - } - public class SterilizeSection : IGridSection - { - public string Title { get; set; } = "살균"; - public ObservableCollection Rows { get; } = new(); - } - - // 예시 Row들 - public class TankRow - { - public DateTime RecordedTime { get; set; } - public WaterTank Tank { get; set; } - } - public class FilterRow - { - public DateTime RecordedTime { get; set; } - public FilteringSystem Filter { get; set; } - } - public class SterRow - { - public DateTime RecordedTime { get; set; } - public SterilizingSystem Sterilizer { get; set; } - } -} diff --git a/SmartAquaViewer/ViewModel/GraphControlViewModel.cs b/SmartAquaViewer/ViewModel/GraphControlViewModel.cs new file mode 100644 index 0000000..f9c60c1 --- /dev/null +++ b/SmartAquaViewer/ViewModel/GraphControlViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmartAquaViewer.ViewModel +{ + class GraphControlViewModel + { + } +} diff --git a/SmartAquaViewer/ViewModel/MonitoringViewModel.cs b/SmartAquaViewer/ViewModel/MonitoringViewModel.cs index fe77212..febea99 100644 --- a/SmartAquaViewer/ViewModel/MonitoringViewModel.cs +++ b/SmartAquaViewer/ViewModel/MonitoringViewModel.cs @@ -21,25 +21,11 @@ namespace SmartAquaViewer.ViewModel public delegate void SystemChangedEventHandler(MonitorTab selectedTab); public event SystemChangedEventHandler OnSystemChanged; - public ObservableCollection GraphTypes { get; } + public ObservableCollection GraphTypes { get; } public List WaterQualityList { get; } public Dictionary> TankGroups { get; } - private string _selectedGraphType; - public string SelectedGraphType - { - get => _selectedGraphType; - set - { - if (_selectedGraphType != value) - { - _selectedGraphType = value; - OnPropertyChanged(); - } - } - } - private MonitorTab _selectedTab; public MonitorTab SelectedTab { @@ -52,24 +38,23 @@ namespace SmartAquaViewer.ViewModel OnPropertyChanged(); Debug.WriteLine($"CurrentTab changed to: {_selectedTab}"); + SetGraphType(); + SelectedGraphType = GraphTypes.FirstOrDefault(); OnSystemChanged?.Invoke(SelectedTab); } } } - private string _currentSystem; - public string CurrentSystem + private GraphType _selectedGraphType; + public GraphType SelectedGraphType { - get => _currentSystem; + get => _selectedGraphType; set { - if (_currentSystem != value) + if (_selectedGraphType != value) { - _currentSystem = value; + _selectedGraphType = value; OnPropertyChanged(); - - SetGraphType(); - SelectedGraphType = GraphTypes.FirstOrDefault() ?? string.Empty; } } } @@ -137,12 +122,11 @@ namespace SmartAquaViewer.ViewModel g => new ObservableCollection( g.OrderBy(r => r.RecordedTime)) ); - - - - GraphTypes = new ObservableCollection(); - CurrentSystem = "Tank"; // Default system + + GraphTypes = new ObservableCollection(); + SelectedTab = MonitorTab.Tank; // Default system SetGraphType(); + SelectedGraphType = GraphTypes.FirstOrDefault(); ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode); } @@ -151,28 +135,28 @@ namespace SmartAquaViewer.ViewModel { GraphTypes.Clear(); - switch (CurrentSystem) + switch (SelectedTab) { - case "Tank": - GraphTypes.Add("LINE"); - GraphTypes.Add("BOX"); - GraphTypes.Add("SCATTER"); + case MonitorTab.Tank: + GraphTypes.Add(GraphType.LINE); + GraphTypes.Add(GraphType.BOX); + GraphTypes.Add(GraphType.SCATTER); break; - case "Filter": - GraphTypes.Add("LINE"); - GraphTypes.Add("STEP"); + case MonitorTab.Filter: + GraphTypes.Add(GraphType.LINE); + GraphTypes.Add(GraphType.STEP); break; - case "Sterilizer": - GraphTypes.Add("LINE"); - GraphTypes.Add("STEP"); + case MonitorTab.Sterilizer: + GraphTypes.Add(GraphType.LINE); + GraphTypes.Add(GraphType.STEP); break; default: break; } string graphTypes = string.Empty; - foreach (string str in GraphTypes) - graphTypes += (str + ", "); + foreach (GraphType graphType in GraphTypes) + graphTypes += (graphType.ToString() + ", "); Debug.WriteLine(graphTypes); }