Files
ENIG/Cs_HMI/AGVLogic/AGVSimulator/Models/SimulatorConfig.cs
backuppc dbaf647d4e refactor: Move AGV development projects to separate AGVLogic folder
- Reorganized AGVMapEditor, AGVNavigationCore, AGVSimulator into AGVLogic folder
- Removed deleted project files from root folder tracking
- Updated CLAUDE.md with AGVLogic-specific development guidelines
- Clean separation of independent project development from main codebase
- Projects now ready for independent development and future integration

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 10:00:40 +09:00

128 lines
3.7 KiB
C#

using System;
using System.IO;
using Newtonsoft.Json;
namespace AGVSimulator.Models
{
/// <summary>
/// 시뮬레이터 환경 설정 클래스
/// </summary>
public class SimulatorConfig
{
#region Properties
/// <summary>
/// MapEditor 실행 파일 경로
/// </summary>
public string MapEditorExecutablePath { get; set; } = string.Empty;
/// <summary>
/// 마지막으로 로드한 맵 파일 경로
/// </summary>
public string LastMapFilePath { get; set; } = string.Empty;
/// <summary>
/// 설정 파일 자동 저장 여부
/// </summary>
public bool AutoSave { get; set; } = true;
/// <summary>
/// 프로그램 시작시 마지막 맵 파일을 자동으로 로드할지 여부
/// </summary>
public bool AutoLoadLastMapFile { get; set; } = true;
#endregion
#region Static Methods
/// <summary>
/// 설정 파일 기본 경로
/// </summary>
private static string ConfigFilePath => Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"AGVSimulator",
"config.json");
/// <summary>
/// 설정을 파일에서 로드
/// </summary>
/// <returns>로드된 설정 객체</returns>
public static SimulatorConfig Load()
{
try
{
if (File.Exists(ConfigFilePath))
{
var json = File.ReadAllText(ConfigFilePath);
return JsonConvert.DeserializeObject<SimulatorConfig>(json) ?? new SimulatorConfig();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"설정 로드 실패: {ex.Message}");
}
return new SimulatorConfig();
}
/// <summary>
/// 설정을 파일에 저장
/// </summary>
/// <param name="config">저장할 설정 객체</param>
/// <returns>저장 성공 여부</returns>
public static bool Save(SimulatorConfig config)
{
try
{
var directory = Path.GetDirectoryName(ConfigFilePath);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
var json = JsonConvert.SerializeObject(config, Formatting.Indented);
File.WriteAllText(ConfigFilePath, json);
return true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"설정 저장 실패: {ex.Message}");
return false;
}
}
#endregion
#region Instance Methods
/// <summary>
/// 현재 설정을 저장
/// </summary>
/// <returns>저장 성공 여부</returns>
public bool Save()
{
return Save(this);
}
/// <summary>
/// MapEditor 실행 파일 경로 유효성 확인
/// </summary>
/// <returns>유효한 경로인지 여부</returns>
public bool IsMapEditorPathValid()
{
return !string.IsNullOrEmpty(MapEditorExecutablePath) &&
File.Exists(MapEditorExecutablePath);
}
/// <summary>
/// 마지막 맵 파일이 존재하는지 확인
/// </summary>
/// <returns>마지막 맵 파일이 유효한지 여부</returns>
public bool HasValidLastMapFile()
{
return !string.IsNullOrEmpty(LastMapFilePath) && File.Exists(LastMapFilePath);
}
#endregion
}
}