This commit is contained in:
backuppc
2025-12-15 17:34:43 +09:00
parent 9db88e5d6b
commit a7f938ff19
29 changed files with 535 additions and 1556 deletions

View File

@@ -33,7 +33,6 @@ namespace Project
bool remoteClose = false;
bool forceClose = false;
readonly usbdetect.DriveDetector usbdet;
public fMain()
{
InitializeComponent();
@@ -57,19 +56,13 @@ namespace Project
if (DateTime.Now > PUB.LastInputTime) PUB.LastInputTime = DateTime.Now;
};
usbdet = new usbdetect.DriveDetector(this);
usbdet.DeviceArrived += Usbdet_DeviceArrived;
usbdet.DeviceRemoved += Usbdet_DeviceRemoved;
PUB._mapCanvas = new AGVNavigationCore.Controls.UnifiedAGVCanvas();
PUB._mapCanvas.Dock = DockStyle.Fill;
PUB._mapCanvas.ShowGrid = false;
PUB._mapCanvas.BackColor = Color.FromArgb(32, 32, 32);
PUB._mapCanvas.ForeColor = Color.White;
this.panTopMenu.MouseMove += LbTitle_MouseMove;
this.panTopMenu.MouseUp += LbTitle_MouseUp;
this.panTopMenu.MouseDown += LbTitle_MouseDown;
@@ -82,33 +75,7 @@ namespace Project
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (usbdet != null)
{
usbdet.WndProc(ref m);
}
}
private void Usbdet_DeviceRemoved(object sender, usbdetect.DriveDetectorEventArgs e)
{
//throw new NotImplementedException();
Console.WriteLine(e.Drive);
}
private void Usbdet_DeviceArrived(object sender, usbdetect.DriveDetectorEventArgs e)
{
//throw new NotImplementedException();
using (var fUpdate = new Dialog.fUpdateForm(e.Drive))
if (fUpdate.ShowDialog() == DialogResult.Yes)
{
//종료한다
remoteClose = true;
this.Close();
}
}
private void __Closing(object sender, FormClosingEventArgs e)
{
// 장치 관리 태스크는 _STEP_CLOSING_START에서 종료됨
@@ -182,6 +149,9 @@ namespace Project
VAR.STR[eVarString.SWVersion] = Application.ProductVersion;
AutoLoadMapData();
//SETTING H/W
this.IOState.ItemClick += gridView2_ItemClick;
VAR.BOOL.PropertyChanged += BOOL_PropertyChanged;
@@ -280,7 +250,7 @@ namespace Project
//수량표시
PUB.counter.PropertyChanged += (s1, e1) => Update_Count();
Update_Count();
PUB.log.Add("프로그램 실행 기록 추가");
PUB.CheckNRegister3(Application.ProductName, "chi", Application.ProductVersion);
@@ -290,6 +260,71 @@ namespace Project
PUB.AddEEDB("프로그램 시작");
}
void AutoLoadMapData()
{
//auto load
var mapPath = new System.IO.DirectoryInfo("route");
if (mapPath.Exists == false) mapPath.Create();
//맵파일로딩
if (PUB.setting.LastMapFile.isEmpty()) PUB.setting.LastMapFile = System.IO.Path.Combine(mapPath.FullName, "default.json");
System.IO.FileInfo filePath = new System.IO.FileInfo(PUB.setting.LastMapFile);
if (filePath.Exists == false) filePath = new System.IO.FileInfo(System.IO.Path.Combine(mapPath.FullName, "default.json"));
if (filePath.Exists == false) //그래도없다면 맵폴더에서 파일을 찾아본다.
{
var files = mapPath.GetFiles("*.json");
if (files.Any()) filePath = files[0];
}
if (filePath.Exists)
{
var result = MapLoader.LoadMapFromFile(filePath.FullName);
if (result.Success)
{
PUB._mapCanvas.SetMapLoadResult(result);
PUB._mapCanvas.MapFileName = filePath.FullName;
// 🔥 가상 AGV 초기화 (첫 노드 위치에 생성)
if (PUB._virtualAGV == null && PUB._mapCanvas.Nodes.Count > 0)
{
var startNode = PUB._mapCanvas.Nodes.FirstOrDefault(n => n.IsNavigationNode());
if (startNode != null)
{
PUB._virtualAGV = new VirtualAGV(PUB.setting.MCID, startNode.Position, AgvDirection.Forward);
PUB._virtualAGV.LowBatteryThreshold = PUB.setting.BatteryLimit_Low;
PUB._virtualAGV.SetPosition(startNode, AgvDirection.Forward);
// 캔버스에 AGV 리스트 설정
var agvList = new System.Collections.Generic.List<AGVNavigationCore.Controls.IAGV> { PUB._virtualAGV };
PUB._mapCanvas.AGVList = agvList;
PUB.log.Add($"가상 AGV 생성: {startNode.Id} 위치");
}
}
else if (PUB._virtualAGV != null)
{
PUB._virtualAGV.LowBatteryThreshold = PUB.setting.BatteryLimit_Low;
// 기존 AGV가 있으면 캔버스에 다시 연결
var agvList = new System.Collections.Generic.List<AGVNavigationCore.Controls.IAGV> { PUB._virtualAGV };
PUB._mapCanvas.AGVList = agvList;
}
PUB.log.Add($"맵 파일 로드 완료: {filePath.Name}, 노드 수: {result.Nodes.Count}");
}
else
{
PUB.log.Add($"맵 파일 로딩 실패: {result.ErrorMessage}");
MessageBox.Show($"맵 파일 로딩 실패: {result.ErrorMessage}", "오류",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
PUB.log.Add($"맵 파일을 찾을 수 없습니다: {filePath.FullName}");
}
}
#region "Mouse Form Move"
private Boolean fMove = false;