파일정리

This commit is contained in:
ChiKyun Kim
2026-01-29 14:03:17 +09:00
parent 00cc0ef5b7
commit 58ca67150d
440 changed files with 47236 additions and 99165 deletions

View File

@@ -0,0 +1,135 @@
using System;
namespace AGVSimulator.Models
{
/// <summary>
/// 시뮬레이션 상태 관리 클래스
/// </summary>
public class SimulationState
{
#region Properties
/// <summary>
/// 시뮬레이션 실행 중 여부
/// </summary>
public bool IsRunning { get; set; }
/// <summary>
/// 시뮬레이션 시작 시간
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 시뮬레이션 경과 시간
/// </summary>
public TimeSpan ElapsedTime => StartTime.HasValue ? DateTime.Now - StartTime.Value : TimeSpan.Zero;
/// <summary>
/// 시뮬레이션 속도 배율 (1.0 = 실시간, 2.0 = 2배속)
/// </summary>
public float SpeedMultiplier { get; set; } = 1.0f;
/// <summary>
/// 총 처리된 이벤트 수
/// </summary>
public int TotalEvents { get; set; }
/// <summary>
/// 총 이동 거리 (모든 AGV 합계)
/// </summary>
public float TotalDistance { get; set; }
/// <summary>
/// 발생한 오류 수
/// </summary>
public int ErrorCount { get; set; }
#endregion
#region Constructor
/// <summary>
/// 기본 생성자
/// </summary>
public SimulationState()
{
Reset();
}
#endregion
#region Public Methods
/// <summary>
/// 시뮬레이션 시작
/// </summary>
public void Start()
{
if (!IsRunning)
{
IsRunning = true;
StartTime = DateTime.Now;
}
}
/// <summary>
/// 시뮬레이션 정지
/// </summary>
public void Stop()
{
IsRunning = false;
}
/// <summary>
/// 시뮬레이션 상태 초기화
/// </summary>
public void Reset()
{
IsRunning = false;
StartTime = null;
SpeedMultiplier = 1.0f;
TotalEvents = 0;
TotalDistance = 0;
ErrorCount = 0;
}
/// <summary>
/// 이벤트 발생 시 호출
/// </summary>
public void RecordEvent()
{
TotalEvents++;
}
/// <summary>
/// 이동 거리 추가
/// </summary>
/// <param name="distance">이동한 거리</param>
public void AddDistance(float distance)
{
TotalDistance += distance;
}
/// <summary>
/// 오류 발생 시 호출
/// </summary>
public void RecordError()
{
ErrorCount++;
}
/// <summary>
/// 통계 정보 조회
/// </summary>
/// <returns>통계 정보 문자열</returns>
public string GetStatistics()
{
return $"실행시간: {ElapsedTime:hh\\:mm\\:ss}, " +
$"이벤트: {TotalEvents}, " +
$"총거리: {TotalDistance:F1}, " +
$"오류: {ErrorCount}";
}
#endregion
}
}

View File

@@ -0,0 +1,128 @@
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
}
}