Compare commits

...

75 Commits

Author SHA1 Message Date
backuppc
18ee01f7bc 로직 확인 중 2026-03-09 17:24:21 +09:00
backuppc
49c40fd371 경로 계산부분 일단 백업(오류있음) 2026-03-09 13:26:14 +09:00
backuppc
30e1ce41ee 경로로직 2026-03-03 17:29:27 +09:00
backuppc
1a4b8a6a54 모든 경로를 전체 정의하기 전 백업 2026-03-03 13:00:13 +09:00
backuppc
6802967cde .. 2026-02-27 17:04:09 +09:00
backuppc
46bed6eb25 턴동작 추가 2026-02-27 16:55:35 +09:00
backuppc
43e7458866 .. 2026-02-27 16:15:30 +09:00
backuppc
03a53d49bf .. 2026-02-27 11:27:30 +09:00
backuppc
71b8a589c6 acs command 창 추가 2026-02-27 09:59:36 +09:00
ChiKyun Kim
24bd2d8a7f .. 2026-02-27 08:58:39 +09:00
ChiKyun Kim
e831752e76 .. 2026-02-26 16:30:58 +09:00
backuppc
c1670ddcbe .. 2026-02-26 14:36:33 +09:00
backuppc
d57b00095c 시스템메세지, 정보메세지개념 추가 2026-02-26 14:18:41 +09:00
backuppc
2e9b7973c7 ai로그 추가 2026-02-26 11:40:57 +09:00
backuppc
1948eda7ea agv정보표시할떄 dist 추가 2026-02-26 11:28:13 +09:00
backuppc
8beaa66516 재시작관련 코드 업데이트 2026-02-26 11:27:07 +09:00
backuppc
c067a76462 속도레벨을 기본 m->l 로 변경, 턴이되어있다면 오류로 처리한다. 2026-02-26 10:34:11 +09:00
backuppc
e7cce4c201 맵 스피드 기본값을 M->L 로 변경함, 버퍼 작업중에는 버퍼외에 다른 명령은 거부하도록 함 2026-02-26 10:00:49 +09:00
backuppc
0e2b407e48 회전중입력된 태그는 무시 2026-02-26 08:45:33 +09:00
ChiKyun Kim
e2691af903 .. 2026-02-25 16:46:51 +09:00
backuppc
2590ad91de .. 2026-02-25 14:55:36 +09:00
backuppc
245749d695 일반노드이동기능 추가 2026-02-25 11:25:09 +09:00
backuppc
6a658879f1 노드정리(삭제노드 제거 및 5번노드 제거로 인한 경로 업데이트) 2026-02-25 11:07:08 +09:00
backuppc
12b3fe50c7 .. 2026-02-24 15:03:52 +09:00
backuppc
dbc53e3146 .. 2026-02-13 14:55:28 +09:00
backuppc
213467fe3f .. 2026-02-13 10:41:10 +09:00
backuppc
d6aed58516 .. 2026-02-12 09:58:01 +09:00
backuppc
2b3a9b3d1d .. 2026-02-12 09:54:14 +09:00
backuppc
a512133d52 Merge branch 'master' of file://k4fs3201n/k4bpartcenter$/Repository/K4/ENIG_AGV 2026-02-10 14:54:10 +09:00
backuppc
471b8ff9c4 .. 2026-02-10 14:53:54 +09:00
ChiKyun Kim
161ff5c3e2 .. 2026-02-09 14:17:11 +09:00
backuppc
c2cc5d67ae 작업시작전에. 현재 위치를 확인하고 진행하게 함. 2026-02-09 13:59:19 +09:00
backuppc
7409528fbd tts에.플레이하도록 수정 2026-02-09 13:21:42 +09:00
ChiKyun Kim
3d5e2bc1e6 .. 2026-02-09 13:21:00 +09:00
backuppc
bd06f59bf1 add tts 2026-02-09 13:06:47 +09:00
backuppc
839486db87 add ttsproject 2026-02-09 13:06:25 +09:00
backuppc
35a057367c acs sequence 2026-02-09 09:43:53 +09:00
ChiKyun Kim
09b1246bbd error fix 2026-02-09 08:48:21 +09:00
ChiKyun Kim
b57c61c6d8 currentnode 값으로 lasttag 값을 복원 2026-02-09 08:41:47 +09:00
ChiKyun Kim
f5f08de0b9 대기상태일때 자동멈춤기능 다시 활성화
remotecontrol 모드 추가, 원격으로 turn, manual, auto 이동시 활성화된다.. 내부코드는 없음. 상태만 추가함, idle 상태일때 자동 멈춤코드가 동작하지 않게 하기 위함이다.
2026-02-09 08:37:39 +09:00
ChiKyun Kim
ddaab0b5da acs test 프로그램에 pick on ,off 기능 추가 2026-02-05 17:18:01 +09:00
backuppc
ba542beaff test_acs 프로젝트 변경 2026-02-05 13:18:20 +09:00
backuppc
ec2af6ac1f chore: commit all remaining changes 2026-02-04 15:26:22 +09:00
backuppc
b388b1917d feat(AGVCanvas): blink error msg, debug info, setview 2026-02-04 15:23:45 +09:00
backuppc
e35dee853f 최종우치에. 이전노드정보와 다음 시작 노드 정보를 모두 추가함.
최초 실행시 선택하는 위치 다이얼로그 제거 후 바로 자동 로딩하도록 함
2026-02-03 17:15:15 +09:00
backuppc
b25be68986 agv 오류코드가 전송되도록함, 에뮬레이터에서 표시되게 함 2026-02-02 15:04:05 +09:00
backuppc
9bca8f67d1 .. 2026-02-02 14:59:48 +09:00
backuppc
02105d49a3 .. 2026-01-30 17:29:54 +09:00
backuppc
faf13f5c37 .. 2026-01-30 16:58:14 +09:00
backuppc
3a8cbd3283 buffer-out 시퀀스 테스트 중 - 리프트 작업 후 이후 동작이 이상함 2026-01-29 17:23:41 +09:00
backuppc
1dde80fa93 buffer in 시퀀스 확인 완료
- 최초 위치확인이 좀 이상하다.
2026-01-29 17:15:08 +09:00
backuppc
af0c32215b 턴 조건 변경 센서->메세지 2026-01-29 15:13:41 +09:00
backuppc
92340308be .. 2026-01-29 14:54:54 +09:00
backuppc
cce51478be .. 2026-01-29 14:53:22 +09:00
backuppc
e99edbe04d Fix oscillation in AGV movement, add command cooldown, and enhance debug logs 2026-01-29 14:51:57 +09:00
ChiKyun Kim
1da1f2de28 .. 2026-01-29 14:24:30 +09:00
ChiKyun Kim
58ca67150d 파일정리 2026-01-29 14:03:17 +09:00
backuppc
00cc0ef5b7 Refactor AGV error handling: Standardize AGVErrorCode usage and update SetRunStepError 2026-01-28 16:45:24 +09:00
backuppc
16d51a2712 refactor: Use SetRunStepError within RunStep sequences
- Refactored _SM_RUN_ENTER, _EXIT, _BUFFER_IN, _BUFFER_OUT, and _Util to use SetRunStepError helper.

- Corrected AGV_RUN_FAIL and MESSAGE_ERROR codes in _SM_RUN_ENTER, _EXIT, and _CHARGE_GO.

- Added new error codes AGV_SPEED_SET_FAIL and AGV_RUN_FAIL to EnumData.cs.
2026-01-28 15:58:42 +09:00
backuppc
5b4fdd33cf feat: Implement RunStep error reporting and refactor charge sequences
- Added RunStepErrorCode to Xbee status protocol and CResult.

- Defined detailed operational error codes in EnumData.cs.

- Updated _SM_RUN_*.cs to report specific error codes before proper error transitions.

- Renamed and refactored charge-related sequence files.
2026-01-28 15:41:03 +09:00
backuppc
ffa6c2fb23 버퍼경로내의 오동작 확인 및 재시작 관련 코드 점검 2026-01-28 10:45:57 +09:00
ChiKyun Kim
b0e75b351a nextstop 시그널을 bool변수에서 agv 으 ㅣspeed = 'L' 조건으로 변경 2026-01-27 16:27:17 +09:00
backuppc
b4d3cd8bb5 .. 2026-01-27 14:11:27 +09:00
backuppc
d8a9007791 . 2026-01-27 14:02:30 +09:00
backuppc
9ee8295489 .. 2026-01-27 14:01:30 +09:00
backuppc
a04a0505d0 .. 2026-01-23 17:33:10 +09:00
backuppc
3b2c1a43a7 경로시뮬레이션완료 2026-01-22 17:11:02 +09:00
backuppc
00c4663ebc .. 2026-01-21 17:28:39 +09:00
backuppc
3044894e5c .. 2026-01-16 17:33:10 +09:00
backuppc
ddf111c69f .. 2026-01-15 17:34:17 +09:00
backuppc
64ff2ecfb9 방향관리를 노드 정보에 추가 2026-01-15 16:16:41 +09:00
backuppc
82592e117d .. 2026-01-15 13:44:56 +09:00
backuppc
0396c61517 Merge branch 'master' of file://k4fs3201n/k4bpartcenter$/Repository/K4/ENIG_AGV 2026-01-14 17:38:18 +09:00
backuppc
b4da1cca00 .. 2026-01-14 17:38:07 +09:00
ChiKyun Kim
48acb5b7b7 update bms data 2026-01-14 16:04:11 +09:00
505 changed files with 63396 additions and 109757 deletions

2
.gitignore vendored
View File

@@ -15,3 +15,5 @@ packages
*.bak
/Cs_HMI/Data/*.agvmap
/Cs_HMI/AGVLogic/AGVMapEditor/Data/*.agvmap
/Document/~$PICkit 프로그램 다운로드 매뉴얼.pptx
/HMI/TestProject/tts/assets

View File

@@ -38,14 +38,12 @@
<ApplicationIcon>icons8-robot-80.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="arCommUtil, Version=25.11.25.2000, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DLL\arCommUtil.dll</HintPath>
</Reference>
<Reference Include="arControl.Net4">
<HintPath>..\Cs_HMI\DLL\arControl.Net4.dll</HintPath>
</Reference>
<Reference Include="ArLog.Net4">
<HintPath>..\Cs_HMI\DLL\ArLog.Net4.dll</HintPath>
</Reference>
<Reference Include="ArSetting.Net4">
<HintPath>..\Cs_HMI\DLL\ArSetting.Net4.dll</HintPath>
<HintPath>..\DLL\arControl.Net4.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -70,16 +68,13 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteStatus.cs" />
<Compile Include="RS232.cs" />
<Compile Include="RunCode\_AGV.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RunCode\_AGV.cs" />
<Compile Include="RunCode\_XBEE.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RunCode\_BMS.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RunCode\_BMS.cs" />
<Compile Include="UC\SerialConn.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -126,15 +121,11 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cs_HMI\AGVLogic\AGVNavigationCore\AGVNavigationCore.csproj">
<ProjectReference Include="..\AGVLogic\AGVNavigationCore\AGVNavigationCore.csproj">
<Project>{c5f7a8b2-8d3e-4a1b-9c6e-7f4d5e2a9b1c}</Project>
<Name>AGVNavigationCore</Name>
</ProjectReference>
<ProjectReference Include="..\Cs_HMI\SubProject\CommUtil\arCommUtil.csproj">
<Project>{14e8c9a5-013e-49ba-b435-ffffff7dd623}</Project>
<Name>arCommUtil</Name>
</ProjectReference>
<ProjectReference Include="..\Cs_HMI\SubProject\EnigProtocol\enigprotocol\ENIGProtocol.csproj">
<ProjectReference Include="..\AGVLogic\ENIGProtocol\enigprotocol\ENIGProtocol.csproj">
<Project>{9365803b-933d-4237-93c7-b502c855a71c}</Project>
<Name>ENIGProtocol</Name>
</ProjectReference>

View File

@@ -5,11 +5,9 @@ VisualStudioVersion = 17.14.36804.6 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVEmulator", "AGVEmulator.csproj", "{9312AB43-72F6-4365-A266-E767215FA7F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVNavigationCore", "..\Cs_HMI\AGVLogic\AGVNavigationCore\AGVNavigationCore.csproj", "{C5F7A8B2-8D3E-4A1B-9C6E-7F4D5E2A9B1C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVNavigationCore", "..\AGVLogic\AGVNavigationCore\AGVNavigationCore.csproj", "{C5F7A8B2-8D3E-4A1B-9C6E-7F4D5E2A9B1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENIGProtocol", "..\Cs_HMI\SubProject\ENIGProtocol\enigprotocol\ENIGProtocol.csproj", "{9365803B-933D-4237-93C7-B502C855A71C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "arCommUtil", "..\Cs_HMI\SubProject\CommUtil\arCommUtil.csproj", "{14E8C9A5-013E-49BA-B435-FFFFFF7DD623}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENIGProtocol", "..\AGVLogic\ENIGProtocol\enigprotocol\ENIGProtocol.csproj", "{9365803B-933D-4237-93C7-B502C855A71C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@@ -1,5 +1,4 @@
using arCtl;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -15,7 +14,8 @@ namespace AGVEmulator
public UInt16 system0 = 0;
public UInt16 system1 = 0;
public UInt16 error = 0;
public byte signal = 0;
public byte signal1 = 0;
public byte signal2 = 0;
public char sts_bunki = 'S';
public char sts_speed = 'L';
public char sts_dir = 'F';
@@ -36,7 +36,19 @@ namespace AGVEmulator
/// <summary>
/// 호출제어기 통신 오류
/// </summary>
controller_comm_error = 11,
controller_comm_error,
/// <summary>
/// 배터리 저전압
/// </summary>
battery_low_voltage,
spare08,
lift_timeout,
lift_driver_overcurrent,
lift_driver_emergency,
/// <summary>
/// 도착경보기 통신 오류
/// </summary>
@@ -57,15 +69,21 @@ namespace AGVEmulator
/// </summary>
cross_ctrl_comm_error,
}
public enum esignal
public enum esignal2
{
cart_detect1 = 0,
cart_detect2,
}
public enum esignal1
{
front_gate_out = 0,
rear_sensor_out,
rear_gte_out,
mark_sensor_1,
mark_sensor_2,
front_left_sensor,
front_right_sensor,
front_center_sensor,
lift_down_sensor,
lift_up_sensor,
magnet_relay,
charger_align_sensor,
}
public enum esystemflag0
@@ -119,7 +137,8 @@ namespace AGVEmulator
system0,
system1,
error,
signal,
signal1,
signal2,
}
public enum estsvaluetype
{
@@ -266,11 +285,17 @@ namespace AGVEmulator
if (SetBit(ref error, idx, value))
ValueChanged?.Invoke(this, new ValueChangedArgs(idx, value, evaluetype.error));
}
public void SetAGV(DevAGV.esignal flag, bool value)
public void SetAGV(DevAGV.esignal1 flag, bool value)
{
var idx = (int)flag;
if (SetBit(ref signal, idx, value))
ValueChanged?.Invoke(this, new ValueChangedArgs(idx, value, evaluetype.signal));
if (SetBit(ref signal1, idx, value))
ValueChanged?.Invoke(this, new ValueChangedArgs(idx, value, evaluetype.signal1));
}
public void SetAGV(DevAGV.esignal2 flag, bool value)
{
var idx = (int)flag;
if (SetBit(ref signal2, idx, value))
ValueChanged?.Invoke(this, new ValueChangedArgs(idx, value, evaluetype.signal2));
}
public void SetSTS(estsvaluetype target, char value)
@@ -311,6 +336,29 @@ namespace AGVEmulator
switch (frame.cmd)
{
case "CLF"://마그넷 * 리프트
var cmd2 = frame.data.Substring(0, 2);
switch(cmd2)
{
case "ON":
SetAGV(esignal1.magnet_relay, true);
break;
case "UP":
SetAGV(esignal1.lift_down_sensor, false);
SetAGV(esignal1.lift_up_sensor, true);
break;
case "DN":
SetAGV(esignal1.lift_up_sensor, false);
SetAGV(esignal1.lift_down_sensor, true);
break;
case "ST":
break;
case "OF":
SetAGV(esignal1.magnet_relay, false);
break;
}
break;
case "CRN": //기동명령
//sts_dir = frame.data[0];
SetSTS(estsvaluetype.direction, frame.data[0]);
@@ -472,11 +520,12 @@ namespace AGVEmulator
barr[20] = (byte)this.sts_bunki;
barr[21] = (byte)this.sts_dir;
barr[22] = (byte)this.sts_sensor;
//bufarr = System.Text.Encoding.Default.GetBytes(p.sensor.ToString().PadLeft(2, '0'));
//Array.Copy(bufarr, 0, barr, 22, bufarr.Length);
bufarr = System.Text.Encoding.Default.GetBytes(signal.ToString("X2").PadLeft(2, '0'));
bufarr = System.Text.Encoding.Default.GetBytes(signal1.ToString("X2").PadLeft(2, '0'));
Array.Copy(bufarr, 0, barr, 23, bufarr.Length);
//barr[22] = (byte)'5';
bufarr = System.Text.Encoding.Default.GetBytes(signal2.ToString("X2").PadLeft(2, '0'));
Array.Copy(bufarr, 0, barr, 25, bufarr.Length);
barr[barr.Length - 3] = (byte)'*';
barr[barr.Length - 2] = (byte)'*';

View File

@@ -74,24 +74,48 @@ namespace AGVEmulator
/// 카트를 가지러 들어간다
/// </summary>
/// <param name="id"></param>
public void SendPickOn(byte id)
public void SendPickOnEnter(byte id)
{
var data = new List<byte>();
data.Add(id);
Send(ENIGProtocol.AGVCommandHE.PickOn, data.ToArray());
Send(ENIGProtocol.AGVCommandHE.PickOnEnter, data.ToArray());
}
/// <summary>
/// 카트를 내려놓
/// 카트를 내려놓으로 들어간
/// </summary>
/// <param name="id"></param>
public void SendPickOff(byte id)
public void SendPickOffEnter(byte id)
{
var data = new List<byte>();
data.Add(id);
Send(ENIGProtocol.AGVCommandHE.PickOff, data.ToArray());
Send(ENIGProtocol.AGVCommandHE.PickOffEnter, data.ToArray());
}
/// <summary>
/// 카트를 가지러 들어가서 나온다
/// </summary>
/// <param name="id"></param>
public void SendPickOnExit(byte id)
{
var data = new List<byte>();
data.Add(id);
Send(ENIGProtocol.AGVCommandHE.PickOnExit, data.ToArray());
}
/// <summary>
/// 카트를 내려놓으러 들어가서 나온다
/// </summary>
/// <param name="id"></param>
public void SendPickOffExit(byte id)
{
var data = new List<byte>();
data.Add(id);
Send(ENIGProtocol.AGVCommandHE.PickOffExit, data.ToArray());
}
public void SendCurrentPos(byte id, uint tag)
{
var data = new List<byte>();

View File

@@ -0,0 +1,50 @@
using System.Text;
namespace AGVEmulator
{
public class RemoteStatus
{
public byte Mode { get; set; } // 0=manual, 1=auto
public byte RunSt { get; set; } // 0=stop, 1=run, 2=error
public byte RunStep { get; set; }
public byte RunStepSeq { get; set; }
public ushort HWError { get; set; }
public byte MotorDir { get; set; } // 0=F, 1=B
public byte MagnetDir { get; set; } // 0=S, 1=L, 2=R
public byte ChargeSt { get; set; } // 0=off, 1=on
public byte CartSt { get; set; } // 0=off, 1=on, 2=unknown
public byte LiftSt { get; set; } // 0=down, 1=up, 2=unknown
public byte ErrorCode { get; set; }
public string LastTag { get; set; }
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Mode: {(Mode == 1 ? "Auto" : "Manual")}");
sb.AppendLine($"RunSt: {(RunSt == 0 ? "Stop" : (RunSt == 1 ? "Run" : "Error"))}");
if (HWError > 0)
{
sb.Append(" [HW ERR: ");
for (int i = 0; i < 16; i++)
{
if ((HWError & (1 << i)) != 0)
{
sb.Append($"{(DevAGV.eerror)i},");
}
}
sb.AppendLine("]");
}
sb.AppendLine($"Step: {RunStep}, Seq: {RunStepSeq}");
sb.AppendLine($"Dir: {(MotorDir == 1 ? "B" : "F")}, Mag: {(MagnetDir == 1 ? "L" : (MagnetDir == 2 ? "R" : "S"))}");
sb.AppendLine($"Charge: {(ChargeSt == 1 ? "ON" : "OFF")}");
sb.AppendLine($"Cart: {(CartSt == 1 ? "ON" : (CartSt == 0 ? "OFF" : "Unk"))}");
sb.AppendLine($"Lift: {(LiftSt == 1 ? "UP" : (LiftSt == 0 ? "DOWN" : "Unk"))}");
sb.Append($"Tag: {LastTag}");
return sb.ToString();
}
}
}

View File

@@ -80,6 +80,7 @@ namespace AGVEmulator
}
break;
}
UpdateUIStatus();
}
private void Agv_ValueChanged(object sender, DevAGV.ValueChangedArgs e)
@@ -142,7 +143,7 @@ namespace AGVEmulator
}
}
break;
case DevAGV.evaluetype.signal:
case DevAGV.evaluetype.signal1:
foreach (CheckBox c in panel8.Controls)
{
var idx = int.Parse(c.Tag.ToString());
@@ -153,7 +154,17 @@ namespace AGVEmulator
}
}
break;
case DevAGV.evaluetype.signal2:
foreach (CheckBox c in panel2.Controls)
{
var idx = int.Parse(c.Tag.ToString());
if (idx == e.Idx)
{
c.Checked = e.Value;
break;
}
}
break;
}
}
@@ -168,7 +179,8 @@ namespace AGVEmulator
aaplycheckboxbit(ref AGV.system0, panel6);
aaplycheckboxbit(ref AGV.system1, panel7);
aaplycheckboxbit(ref AGV.error, panel9);
aaplycheckboxbit(ref AGV.signal, panel8);
aaplycheckboxbit(ref AGV.signal1, panel8);
aaplycheckboxbit(ref AGV.signal2, panel2);
if (this.agvViewer1.StopbyMark) AGV.sts_speed = 'S';
else AGV.sts_speed = GetGroupItemCheckbox(groupBox4);

View File

@@ -24,15 +24,44 @@ namespace AGVEmulator
}
private void CAL_ProtocReceived(object sender, ENIG.EEProtocol.DataEventArgs e)
{
//throw new NotImplementedException();
var dev = (DeviceType)e.ReceivedPacket.ID;
if (dev == DeviceType.AGV1 || dev == DeviceType.AGV2)
// HMI(Host)에서 호스트로 취급되는 HMI가 보낸 패킷은 ID가 0(ACS)임.
// 하지만 xbee.cs에서 CreatePacket 시 PUB.setting.XBE_ID를 사용함.
// 에뮬레이터에서는 이 패킷들을 수신하여 상태를 업데이트함.
var cmd = (ENIGProtocol.AGVCommandEH)e.ReceivedPacket.Command;
var data = e.ReceivedPacket.Data;
if (cmd == ENIGProtocol.AGVCommandEH.Status)
{
//agv에서 들어오는 데이터
var cmd = e.ReceivedPacket.Command;
if(cmd == 3)
if (data.Length >= 16)
{
//status
_remoteStatus.Mode = data[0];
_remoteStatus.RunSt = data[1];
_remoteStatus.HWError = BitConverter.ToUInt16(data, 2);
_remoteStatus.RunStep = data[4];
_remoteStatus.RunStepSeq = data[5];
_remoteStatus.MotorDir = data[6];
_remoteStatus.MagnetDir = data[7];
_remoteStatus.ChargeSt = data[8];
_remoteStatus.CartSt = data[9];
_remoteStatus.LiftSt = data[10];
_remoteStatus.ErrorCode = data[11];
_remoteErrorCode = (ENIGProtocol.AGVErrorCode)data[11];
_remoteErrorMessage = ENIGProtocol.AGVUtility.GetAGVErrorMessage(_remoteErrorCode);
_remoteStatus.LastTag = Encoding.ASCII.GetString(data, 12, 4);
UpdateUIStatus();
}
}
else if (cmd == ENIGProtocol.AGVCommandEH.Error)
{
if (data.Length >= 1)
{
_remoteErrorCode = (ENIGProtocol.AGVErrorCode)data[0];
// _remoteErrorMessage = ... Error 메시지 자체는 패킷에 포함되지 않으므로 유틸리티 사용 가능
_remoteErrorMessage = ENIGProtocol.AGVUtility.GetAGVErrorMessage(_remoteErrorCode);
UpdateUIStatus();
}
}
}

View File

@@ -32,34 +32,34 @@ namespace AGVEmulator
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
AGVEmulator.UC.AgvViewer.ptdata ptdata57 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata58 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata59 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata60 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata61 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata62 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata63 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata64 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata65 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata66 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata67 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata68 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata69 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata70 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata71 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata72 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata73 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata74 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata75 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata76 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata77 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata78 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata79 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata80 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata81 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata82 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata83 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata84 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata29 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata30 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata31 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata32 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata33 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata34 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata35 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata36 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata37 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata38 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata39 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata40 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata41 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata42 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata43 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata44 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata45 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata46 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata47 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata48 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata49 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata50 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata51 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata52 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata53 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata54 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata55 = new AGVEmulator.UC.AgvViewer.ptdata();
AGVEmulator.UC.AgvViewer.ptdata ptdata56 = new AGVEmulator.UC.AgvViewer.ptdata();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(fMain));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.rtBMS = new arCtl.LogTextBox();
@@ -91,6 +91,7 @@ namespace AGVEmulator
this.panel4 = new System.Windows.Forms.Panel();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.panel2 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.panel9 = new System.Windows.Forms.Panel();
@@ -141,6 +142,17 @@ namespace AGVEmulator
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.panel3 = new System.Windows.Forms.Panel();
this.groupBox13 = new System.Windows.Forms.GroupBox();
this.tbErCode = new System.Windows.Forms.TextBox();
this.tbErmsg = new System.Windows.Forms.TextBox();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.rtStatus = new System.Windows.Forms.RichTextBox();
this.label13 = new System.Windows.Forms.Label();
this.button6 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.nudIDAgv = new System.Windows.Forms.NumericUpDown();
this.label7 = new System.Windows.Forms.Label();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
@@ -167,8 +179,6 @@ namespace AGVEmulator
this.sbBMS = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.sbCAL = new System.Windows.Forms.ToolStripStatusLabel();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trbT2)).BeginInit();
@@ -195,6 +205,8 @@ namespace AGVEmulator
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
this.panel3.SuspendLayout();
this.groupBox13.SuspendLayout();
this.groupBox12.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudTagNo)).BeginInit();
@@ -563,6 +575,7 @@ namespace AGVEmulator
//
// groupBox10
//
this.groupBox10.Controls.Add(this.panel2);
this.groupBox10.Controls.Add(this.panel8);
this.groupBox10.Dock = System.Windows.Forms.DockStyle.Left;
this.groupBox10.Location = new System.Drawing.Point(652, 44);
@@ -572,16 +585,25 @@ namespace AGVEmulator
this.groupBox10.TabStop = false;
this.groupBox10.Text = "signal";
//
// panel2
//
this.panel2.AutoScroll = true;
this.panel2.AutoSize = true;
this.panel2.Location = new System.Drawing.Point(3, 162);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(183, 68);
this.panel2.TabIndex = 1;
this.panel2.Tag = "sg2";
//
// panel8
//
this.panel8.AutoScroll = true;
this.panel8.AutoSize = true;
this.panel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel8.Location = new System.Drawing.Point(3, 17);
this.panel8.Location = new System.Drawing.Point(5, 11);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(183, 213);
this.panel8.Size = new System.Drawing.Size(180, 127);
this.panel8.TabIndex = 1;
this.panel8.Tag = "sg";
this.panel8.Tag = "sg1";
//
// groupBox11
//
@@ -1104,120 +1126,120 @@ namespace AGVEmulator
this.agvViewer1.lastmarkdir = "";
this.agvViewer1.lasttag = "";
this.agvViewer1.lasttagdir = "";
ptdata57.active = false;
ptdata57.data = "NOT";
ptdata57.pos = 30F;
ptdata58.active = false;
ptdata58.data = "QA";
ptdata58.pos = 200F;
ptdata59.active = false;
ptdata59.data = "CHG";
ptdata59.pos = 300F;
ptdata60.active = false;
ptdata60.data = "QC";
ptdata60.pos = 400F;
ptdata61.active = false;
ptdata61.data = "#FVI-1";
ptdata61.pos = 500F;
ptdata62.active = false;
ptdata62.data = "#FVI-2";
ptdata62.pos = 600F;
ptdata63.active = false;
ptdata63.data = "#FVI-3";
ptdata63.pos = 700F;
ptdata64.active = false;
ptdata64.data = "#FVI-4";
ptdata64.pos = 800F;
ptdata65.active = false;
ptdata65.data = "#FVI-5";
ptdata65.pos = 900F;
ptdata66.active = false;
ptdata66.data = "POT";
ptdata66.pos = 970F;
ptdata29.active = false;
ptdata29.data = "NOT";
ptdata29.pos = 30F;
ptdata30.active = false;
ptdata30.data = "QA";
ptdata30.pos = 200F;
ptdata31.active = false;
ptdata31.data = "CHG";
ptdata31.pos = 300F;
ptdata32.active = false;
ptdata32.data = "QC";
ptdata32.pos = 400F;
ptdata33.active = false;
ptdata33.data = "#FVI-1";
ptdata33.pos = 500F;
ptdata34.active = false;
ptdata34.data = "#FVI-2";
ptdata34.pos = 600F;
ptdata35.active = false;
ptdata35.data = "#FVI-3";
ptdata35.pos = 700F;
ptdata36.active = false;
ptdata36.data = "#FVI-4";
ptdata36.pos = 800F;
ptdata37.active = false;
ptdata37.data = "#FVI-5";
ptdata37.pos = 900F;
ptdata38.active = false;
ptdata38.data = "POT";
ptdata38.pos = 970F;
this.agvViewer1.listMRK = new AGVEmulator.UC.AgvViewer.ptdata[] {
ptdata57,
ptdata58,
ptdata59,
ptdata60,
ptdata61,
ptdata62,
ptdata63,
ptdata64,
ptdata65,
ptdata66};
ptdata67.active = false;
ptdata67.data = "9000";
ptdata67.pos = 80F;
ptdata68.active = false;
ptdata68.data = "9001";
ptdata68.pos = 120F;
ptdata69.active = false;
ptdata69.data = "9010";
ptdata69.pos = 180F;
ptdata70.active = false;
ptdata70.data = "9011";
ptdata70.pos = 220F;
ptdata71.active = false;
ptdata71.data = "9020";
ptdata71.pos = 280F;
ptdata72.active = false;
ptdata72.data = "9021";
ptdata72.pos = 320F;
ptdata73.active = false;
ptdata73.data = "9030";
ptdata73.pos = 380F;
ptdata74.active = false;
ptdata74.data = "9031";
ptdata74.pos = 420F;
ptdata75.active = false;
ptdata75.data = "9040";
ptdata75.pos = 480F;
ptdata76.active = false;
ptdata76.data = "9041";
ptdata76.pos = 520F;
ptdata77.active = false;
ptdata77.data = "9050";
ptdata77.pos = 580F;
ptdata78.active = false;
ptdata78.data = "9051";
ptdata78.pos = 620F;
ptdata79.active = false;
ptdata79.data = "9060";
ptdata79.pos = 680F;
ptdata80.active = false;
ptdata80.data = "9061";
ptdata80.pos = 720F;
ptdata81.active = false;
ptdata81.data = "9070";
ptdata81.pos = 780F;
ptdata82.active = false;
ptdata82.data = "9071";
ptdata82.pos = 820F;
ptdata83.active = false;
ptdata83.data = "9000";
ptdata83.pos = 10F;
ptdata84.active = false;
ptdata84.data = "9001";
ptdata84.pos = 50F;
ptdata29,
ptdata30,
ptdata31,
ptdata32,
ptdata33,
ptdata34,
ptdata35,
ptdata36,
ptdata37,
ptdata38};
ptdata39.active = false;
ptdata39.data = "9000";
ptdata39.pos = 80F;
ptdata40.active = false;
ptdata40.data = "9001";
ptdata40.pos = 120F;
ptdata41.active = false;
ptdata41.data = "9010";
ptdata41.pos = 180F;
ptdata42.active = false;
ptdata42.data = "9011";
ptdata42.pos = 220F;
ptdata43.active = false;
ptdata43.data = "9020";
ptdata43.pos = 280F;
ptdata44.active = false;
ptdata44.data = "9021";
ptdata44.pos = 320F;
ptdata45.active = false;
ptdata45.data = "9030";
ptdata45.pos = 380F;
ptdata46.active = false;
ptdata46.data = "9031";
ptdata46.pos = 420F;
ptdata47.active = false;
ptdata47.data = "9040";
ptdata47.pos = 480F;
ptdata48.active = false;
ptdata48.data = "9041";
ptdata48.pos = 520F;
ptdata49.active = false;
ptdata49.data = "9050";
ptdata49.pos = 580F;
ptdata50.active = false;
ptdata50.data = "9051";
ptdata50.pos = 620F;
ptdata51.active = false;
ptdata51.data = "9060";
ptdata51.pos = 680F;
ptdata52.active = false;
ptdata52.data = "9061";
ptdata52.pos = 720F;
ptdata53.active = false;
ptdata53.data = "9070";
ptdata53.pos = 780F;
ptdata54.active = false;
ptdata54.data = "9071";
ptdata54.pos = 820F;
ptdata55.active = false;
ptdata55.data = "9000";
ptdata55.pos = 10F;
ptdata56.active = false;
ptdata56.data = "9001";
ptdata56.pos = 50F;
this.agvViewer1.listTAG = new AGVEmulator.UC.AgvViewer.ptdata[] {
ptdata67,
ptdata68,
ptdata69,
ptdata70,
ptdata71,
ptdata72,
ptdata73,
ptdata74,
ptdata75,
ptdata76,
ptdata77,
ptdata78,
ptdata79,
ptdata80,
ptdata81,
ptdata82,
ptdata83,
ptdata84};
ptdata39,
ptdata40,
ptdata41,
ptdata42,
ptdata43,
ptdata44,
ptdata45,
ptdata46,
ptdata47,
ptdata48,
ptdata49,
ptdata50,
ptdata51,
ptdata52,
ptdata53,
ptdata54,
ptdata55,
ptdata56};
this.agvViewer1.Location = new System.Drawing.Point(241, 0);
this.agvViewer1.Name = "agvViewer1";
this.agvViewer1.Size = new System.Drawing.Size(899, 120);
@@ -1262,6 +1284,12 @@ namespace AGVEmulator
//
// panel3
//
this.panel3.Controls.Add(this.groupBox13);
this.panel3.Controls.Add(this.groupBox12);
this.panel3.Controls.Add(this.label13);
this.panel3.Controls.Add(this.button6);
this.panel3.Controls.Add(this.button13);
this.panel3.Controls.Add(this.label12);
this.panel3.Controls.Add(this.button3);
this.panel3.Controls.Add(this.button2);
this.panel3.Controls.Add(this.nudIDAgv);
@@ -1282,10 +1310,117 @@ namespace AGVEmulator
this.panel3.Size = new System.Drawing.Size(364, 622);
this.panel3.TabIndex = 15;
//
// groupBox13
//
this.groupBox13.Controls.Add(this.tbErCode);
this.groupBox13.Controls.Add(this.tbErmsg);
this.groupBox13.Dock = System.Windows.Forms.DockStyle.Bottom;
this.groupBox13.Location = new System.Drawing.Point(0, 545);
this.groupBox13.Name = "groupBox13";
this.groupBox13.Size = new System.Drawing.Size(364, 77);
this.groupBox13.TabIndex = 21;
this.groupBox13.TabStop = false;
this.groupBox13.Text = "error";
//
// tbErCode
//
this.tbErCode.Location = new System.Drawing.Point(12, 18);
this.tbErCode.Name = "tbErCode";
this.tbErCode.Size = new System.Drawing.Size(287, 21);
this.tbErCode.TabIndex = 1;
//
// tbErmsg
//
this.tbErmsg.Location = new System.Drawing.Point(13, 45);
this.tbErmsg.Name = "tbErmsg";
this.tbErmsg.Size = new System.Drawing.Size(287, 21);
this.tbErmsg.TabIndex = 0;
//
// groupBox12
//
this.groupBox12.Controls.Add(this.rtStatus);
this.groupBox12.Location = new System.Drawing.Point(7, 318);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(355, 221);
this.groupBox12.TabIndex = 20;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "status";
//
// rtStatus
//
this.rtStatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtStatus.Location = new System.Drawing.Point(3, 17);
this.rtStatus.Name = "rtStatus";
this.rtStatus.Size = new System.Drawing.Size(349, 201);
this.rtStatus.TabIndex = 0;
this.rtStatus.Text = "";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(18, 287);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(26, 12);
this.label13.TabIndex = 19;
this.label13.Text = "Exit";
//
// button6
//
this.button6.Location = new System.Drawing.Point(205, 274);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(133, 38);
this.button6.TabIndex = 18;
this.button6.Tag = "--";
this.button6.Text = "Pick Off";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click_1);
//
// button13
//
this.button13.Location = new System.Drawing.Point(66, 274);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(133, 38);
this.button13.TabIndex = 17;
this.button13.Tag = "--";
this.button13.Text = "Pick On";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.button13_Click);
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(18, 243);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(34, 12);
this.label12.TabIndex = 16;
this.label12.Text = "Enter";
//
// button3
//
this.button3.Location = new System.Drawing.Point(205, 230);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(133, 38);
this.button3.TabIndex = 15;
this.button3.Tag = "--";
this.button3.Text = "Pick Off";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(66, 230);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(133, 38);
this.button2.TabIndex = 14;
this.button2.Tag = "--";
this.button2.Text = "Pick On";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// nudIDAgv
//
this.nudIDAgv.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.nudIDAgv.Location = new System.Drawing.Point(6, 249);
this.nudIDAgv.Location = new System.Drawing.Point(7, 174);
this.nudIDAgv.Maximum = new decimal(new int[] {
9999999,
0,
@@ -1304,7 +1439,7 @@ namespace AGVEmulator
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(32, 220);
this.label7.Location = new System.Drawing.Point(33, 145);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(45, 12);
this.label7.TabIndex = 12;
@@ -1313,7 +1448,7 @@ namespace AGVEmulator
// numericUpDown2
//
this.numericUpDown2.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.numericUpDown2.Location = new System.Drawing.Point(110, 207);
this.numericUpDown2.Location = new System.Drawing.Point(111, 132);
this.numericUpDown2.Maximum = new decimal(new int[] {
9999999,
0,
@@ -1331,7 +1466,7 @@ namespace AGVEmulator
//
// button1
//
this.button1.Location = new System.Drawing.Point(246, 207);
this.button1.Location = new System.Drawing.Point(247, 132);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(86, 38);
this.button1.TabIndex = 10;
@@ -1343,7 +1478,7 @@ namespace AGVEmulator
// nudTagNo
//
this.nudTagNo.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.nudTagNo.Location = new System.Drawing.Point(110, 251);
this.nudTagNo.Location = new System.Drawing.Point(111, 176);
this.nudTagNo.Maximum = new decimal(new int[] {
9999999,
0,
@@ -1361,7 +1496,7 @@ namespace AGVEmulator
//
// btacsgoto
//
this.btacsgoto.Location = new System.Drawing.Point(246, 251);
this.btacsgoto.Location = new System.Drawing.Point(247, 176);
this.btacsgoto.Name = "btacsgoto";
this.btacsgoto.Size = new System.Drawing.Size(86, 38);
this.btacsgoto.TabIndex = 8;
@@ -1372,7 +1507,7 @@ namespace AGVEmulator
//
// button7
//
this.button7.Location = new System.Drawing.Point(83, 72);
this.button7.Location = new System.Drawing.Point(219, 12);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(62, 54);
this.button7.TabIndex = 7;
@@ -1381,7 +1516,7 @@ namespace AGVEmulator
//
// button8
//
this.button8.Location = new System.Drawing.Point(83, 132);
this.button8.Location = new System.Drawing.Point(87, 72);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(62, 54);
this.button8.TabIndex = 6;
@@ -1391,7 +1526,7 @@ namespace AGVEmulator
//
// button9
//
this.button9.Location = new System.Drawing.Point(15, 130);
this.button9.Location = new System.Drawing.Point(19, 70);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(62, 54);
this.button9.TabIndex = 5;
@@ -1401,7 +1536,7 @@ namespace AGVEmulator
//
// button10
//
this.button10.Location = new System.Drawing.Point(15, 70);
this.button10.Location = new System.Drawing.Point(151, 10);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(62, 54);
this.button10.TabIndex = 3;
@@ -1542,28 +1677,6 @@ namespace AGVEmulator
this.sbCAL.Size = new System.Drawing.Size(19, 17);
this.sbCAL.Text = "●";
//
// button2
//
this.button2.Location = new System.Drawing.Point(246, 295);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(86, 38);
this.button2.TabIndex = 14;
this.button2.Tag = "--";
this.button2.Text = "Pick On";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(246, 339);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(86, 38);
this.button3.TabIndex = 15;
this.button3.Tag = "--";
this.button3.Text = "Pick Off";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// fMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -1612,6 +1725,9 @@ namespace AGVEmulator
this.tabPage3.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.groupBox13.ResumeLayout(false);
this.groupBox13.PerformLayout();
this.groupBox12.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudTagNo)).EndInit();
@@ -1734,6 +1850,16 @@ namespace AGVEmulator
private ToolStripButton toolStripButton5;
private Button button3;
private Button button2;
private Panel panel2;
private Label label12;
private Label label13;
private Button button6;
private Button button13;
private GroupBox groupBox13;
private GroupBox groupBox12;
private TextBox tbErCode;
private TextBox tbErmsg;
private RichTextBox rtStatus;
}
}

View File

@@ -8,22 +8,26 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using static AGVEmulator.DevAGV;
using AGVNavigationCore.Controls;
using AGVNavigationCore.Models;
using System.Text;
namespace AGVEmulator
{
public partial class fMain : Form
{
arUtil.Log logAGV, logBMS, logCAL;
AR.Log logAGV, logBMS, logCAL;
DevBMS BMS;
DevAGV AGV;
DevXBE XBE;
public RemoteStatus _remoteStatus = new RemoteStatus();
public ENIGProtocol.AGVErrorCode _remoteErrorCode = ENIGProtocol.AGVErrorCode.None;
public string _remoteErrorMessage = "";
// Map Control
private UnifiedAGVCanvas _agvCanvas;
private VirtualAGV _visualAgv;
@@ -47,9 +51,9 @@ namespace AGVEmulator
InitializeComponent();
this.Text = $"{Application.ProductName} ver.{Application.ProductVersion}";
// logPLC = new arUtil.Log();
logAGV = new arUtil.Log();
logBMS = new arUtil.Log();
logCAL = new arUtil.Log();
logAGV = new AR.Log();
logBMS = new AR.Log();
logCAL = new AR.Log();
// logPLC.FileNameFormat = "{yyyyMMdd}_PLC";
logAGV.FileNameFormat = "{yyyyMMdd}_AGV";
@@ -153,10 +157,10 @@ namespace AGVEmulator
chk.CheckedChanged += Chk_CheckedChanged;
this.panel7.Controls.Add(chk);
}
arrs = Enum.GetNames(typeof(DevAGV.esignal));
arrs = Enum.GetNames(typeof(DevAGV.esignal1));
foreach (var item in arrs)
{
var data = (DevAGV.esignal)Enum.Parse(typeof(DevAGV.esignal), item);
var data = (DevAGV.esignal1)Enum.Parse(typeof(DevAGV.esignal1), item);
var chk = new CheckBox();
chk.Text = $"[{(int)data:00}] {item}";
@@ -167,6 +171,20 @@ namespace AGVEmulator
chk.CheckedChanged += Chk_CheckedChanged;
this.panel8.Controls.Add(chk);
}
arrs = Enum.GetNames(typeof(DevAGV.esignal2));
foreach (var item in arrs)
{
var data = (DevAGV.esignal2)Enum.Parse(typeof(DevAGV.esignal2), item);
var chk = new CheckBox();
chk.Text = $"[{(int)data:00}] {item}";
chk.AutoSize = true;
chk.Visible = true;
chk.Tag = (int)data;
chk.Dock = DockStyle.Top;
chk.CheckedChanged += Chk_CheckedChanged;
this.panel2.Controls.Add(chk);
}
arrs = Enum.GetNames(typeof(DevAGV.eerror));
foreach (var item in arrs)
{
@@ -344,7 +362,7 @@ namespace AGVEmulator
private void AgvViewer1_MarkTouched(object sender, UC.AgvViewer.TagArgs e)
{
// throw new NotImplementedException();
AGV.SetAGV(esignal.mark_sensor_1, e.Active);
AGV.SetAGV(esignal1.mark_sensor_1, e.Active);
logAGV.Add($"mark {e.Data} touch:{e.Active}");
}
@@ -730,10 +748,14 @@ namespace AGVEmulator
var v2 = (DevAGV.eerror)idx;
AGV.SetAGV(v2, chk.Checked);
break;
case "sg":
var v3 = (DevAGV.esignal)idx;
case "sg1":
var v3 = (DevAGV.esignal1)idx;
AGV.SetAGV(v3, chk.Checked);
break;
case "sg2":
var v4 = (DevAGV.esignal2)idx;
AGV.SetAGV(v4, chk.Checked);
break;
}
chk.BackColor = chk.Checked ? Color.Lime : SystemColors.Window;
@@ -920,21 +942,25 @@ namespace AGVEmulator
private void button2_Click(object sender, EventArgs e)
{
var target = (byte)nudIDAgv.Value;
this.XBE.SendPickOn(target);
this.XBE.SendPickOnEnter(target);
}
private void button3_Click(object sender, EventArgs e)
{
var target = (byte)nudIDAgv.Value;
this.XBE.SendPickOff(target);
this.XBE.SendPickOffEnter(target);
}
private void trbT2_Scroll(object sender, EventArgs e)
{
Temp2 = (UInt16)trbT2.Value;
label11.Text = $"{Temp2 / 10f}º";
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
serAGV.Connect();
@@ -948,8 +974,59 @@ namespace AGVEmulator
serBMS.Disconnect();
serCAL.Disconnect();
}
private void button13_Click(object sender, EventArgs e)
{
var target = (byte)nudIDAgv.Value;
this.XBE.SendPickOnExit(target);
}
private void button6_Click_1(object sender, EventArgs e)
{
var target = (byte)nudIDAgv.Value;
this.XBE.SendPickOffExit(target);
}
public void UpdateUIStatus()
{
if (this.InvokeRequired)
{
this.BeginInvoke(new Action(UpdateUIStatus));
return;
}
rtStatus.Text = _remoteStatus.ToString();
string errCode = _remoteErrorCode.ToString();
string errMsg = _remoteErrorMessage;
if (_remoteStatus.HWError > 0)
{
errCode = $"HW:{_remoteStatus.HWError:X4}" + (errCode == "None" ? "" : $" | {errCode}");
StringBuilder sbHw = new StringBuilder();
for (int i = 0; i < 16; i++)
{
if (((ushort)_remoteStatus.HWError & (1 << i)) != 0)
{
sbHw.Append($"{(DevAGV.eerror)i}, ");
}
}
errMsg = $"[HW] {sbHw}" + (string.IsNullOrEmpty(errMsg) ? "" : $" | {errMsg}");
}
tbErCode.Text = errCode;
tbErmsg.Text = errMsg;
if (_remoteErrorCode != ENIGProtocol.AGVErrorCode.None || _remoteStatus.HWError > 0)
{
tbErCode.BackColor = Color.Red;
tbErCode.ForeColor = Color.White;
}
else
{
tbErCode.BackColor = SystemColors.Window;
tbErCode.ForeColor = SystemColors.WindowText;
}
}
}
}

View File

@@ -1,6 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 15 for Windows Desktop
VisualStudioVersion = 15.0.36324.19
# Visual Studio Version 17
VisualStudioVersion = 17.14.36310.24
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVMapEditor", "AGVMapEditor\AGVMapEditor.csproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}"
EndProject
@@ -8,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVNavigationCore", "AGVNav
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGVSimulator", "AGVSimulator\AGVSimulator.csproj", "{B2C3D4E5-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENIGProtocol", "EnigProtocol\enigprotocol\ENIGProtocol.csproj", "{9365803B-933D-4237-93C7-B502C855A71C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -26,11 +29,15 @@ Global
{B2C3D4E5-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2C3D4E5-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2C3D4E5-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{9365803B-933D-4237-93C7-B502C855A71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9365803B-933D-4237-93C7-B502C855A71C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9365803B-933D-4237-93C7-B502C855A71C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9365803B-933D-4237-93C7-B502C855A71C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F2C60284-CCB5-450D-BCD0-19C693529FD6}
SolutionGuid = {638744DA-A7C8-43E2-A98E-0DE9BDB1DA35}
EndGlobalSection
EndGlobal

View File

@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\..\Amkor\AGV4\Test\MapEditor\</OutputPath>
<OutputPath>bin\debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View File

@@ -31,6 +31,7 @@ namespace AGVMapEditor.Forms
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.sbFile = new System.Windows.Forms.ToolStripStatusLabel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPageNodes = new System.Windows.Forms.TabPage();
@@ -40,6 +41,20 @@ namespace AGVMapEditor.Forms
this.lstNodeConnection = new System.Windows.Forms.ListBox();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.btNodeRemove = new System.Windows.Forms.ToolStripButton();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.lstMagnetDirection = new System.Windows.Forms.ListBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.toolStrip4 = new System.Windows.Forms.ToolStrip();
this.btDirDelete = new System.Windows.Forms.ToolStripButton();
this.btMakeDirdata = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.lstMagnet = new System.Windows.Forms.ListBox();
this.toolStrip5 = new System.Windows.Forms.ToolStrip();
this.btDelMagnet = new System.Windows.Forms.ToolStripButton();
this._propertyGrid = new System.Windows.Forms.PropertyGrid();
this.panel1 = new System.Windows.Forms.Panel();
this.toolStrip3 = new System.Windows.Forms.ToolStrip();
@@ -51,11 +66,12 @@ namespace AGVMapEditor.Forms
this.btnDelete = new System.Windows.Forms.ToolStripButton();
this.btnEditImage = new System.Windows.Forms.ToolStripButton();
this.separator1 = new System.Windows.Forms.ToolStripSeparator();
this.btnConnect = new System.Windows.Forms.ToolStripButton();
this.btnDeleteConnection = new System.Windows.Forms.ToolStripButton();
this.btnConnNode = new System.Windows.Forms.ToolStripButton();
this.btnConnDir = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.btnToggleGrid = new System.Windows.Forms.ToolStripButton();
this.btnFitMap = new System.Windows.Forms.ToolStripButton();
this.btAddMagnet = new System.Windows.Forms.ToolStripButton();
this.toolStrip2 = new System.Windows.Forms.ToolStrip();
this.btnNew = new System.Windows.Forms.ToolStripButton();
this.btnOpen = new System.Windows.Forms.ToolStripButton();
@@ -67,6 +83,7 @@ namespace AGVMapEditor.Forms
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButton1 = new System.Windows.Forms.ToolStripDropDownButton();
this.allTurnLeftRightCrossOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -76,6 +93,11 @@ namespace AGVMapEditor.Forms
this.tabPageNodes.SuspendLayout();
this.tabPage1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.toolStrip4.SuspendLayout();
this.tabPage3.SuspendLayout();
this.toolStrip5.SuspendLayout();
this.toolStrip3.SuspendLayout();
this.toolStrip2.SuspendLayout();
this.SuspendLayout();
@@ -83,7 +105,8 @@ namespace AGVMapEditor.Forms
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
this.toolStripStatusLabel1,
this.sbFile});
this.statusStrip1.Location = new System.Drawing.Point(0, 751);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(1200, 22);
@@ -96,6 +119,12 @@ namespace AGVMapEditor.Forms
this.toolStripStatusLabel1.Size = new System.Drawing.Size(39, 17);
this.toolStripStatusLabel1.Text = "Ready";
//
// sbFile
//
this.sbFile.Name = "sbFile";
this.sbFile.Size = new System.Drawing.Size(17, 17);
this.sbFile.Text = "--";
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -120,6 +149,8 @@ namespace AGVMapEditor.Forms
//
this.tabControl1.Controls.Add(this.tabPageNodes);
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
@@ -201,6 +232,161 @@ namespace AGVMapEditor.Forms
this.btNodeRemove.Text = "Remove";
this.btNodeRemove.Click += new System.EventHandler(this.btNodeRemove_Click);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.lstMagnetDirection);
this.tabPage2.Controls.Add(this.tableLayoutPanel1);
this.tabPage2.Controls.Add(this.toolStrip4);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(292, 309);
this.tabPage2.TabIndex = 2;
this.tabPage2.Text = "방향 관리";
this.tabPage2.UseVisualStyleBackColor = true;
//
// lstMagnetDirection
//
this.lstMagnetDirection.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstMagnetDirection.FormattingEnabled = true;
this.lstMagnetDirection.ItemHeight = 12;
this.lstMagnetDirection.Location = new System.Drawing.Point(0, 25);
this.lstMagnetDirection.Name = "lstMagnetDirection";
this.lstMagnetDirection.Size = new System.Drawing.Size(292, 246);
this.lstMagnetDirection.TabIndex = 3;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.Controls.Add(this.button1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.button2, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.button3, 2, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 271);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 38F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(292, 38);
this.tableLayoutPanel1.TabIndex = 6;
//
// button1
//
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
this.button1.Location = new System.Drawing.Point(3, 3);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(91, 32);
this.button1.TabIndex = 0;
this.button1.Text = "Left";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Dock = System.Windows.Forms.DockStyle.Fill;
this.button2.Location = new System.Drawing.Point(100, 3);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(91, 32);
this.button2.TabIndex = 0;
this.button2.Text = "Straight";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Dock = System.Windows.Forms.DockStyle.Fill;
this.button3.Location = new System.Drawing.Point(197, 3);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(92, 32);
this.button3.TabIndex = 0;
this.button3.Text = "Right";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// toolStrip4
//
this.toolStrip4.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btDirDelete,
this.btMakeDirdata,
this.toolStripButton2});
this.toolStrip4.Location = new System.Drawing.Point(0, 0);
this.toolStrip4.Name = "toolStrip4";
this.toolStrip4.Size = new System.Drawing.Size(292, 25);
this.toolStrip4.TabIndex = 5;
this.toolStrip4.Text = "toolStrip4";
//
// btDirDelete
//
this.btDirDelete.Image = ((System.Drawing.Image)(resources.GetObject("btDirDelete.Image")));
this.btDirDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btDirDelete.Name = "btDirDelete";
this.btDirDelete.Size = new System.Drawing.Size(61, 22);
this.btDirDelete.Text = "Delete";
this.btDirDelete.Click += new System.EventHandler(this.btDirDelete_Click);
//
// btMakeDirdata
//
this.btMakeDirdata.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.btMakeDirdata.Image = ((System.Drawing.Image)(resources.GetObject("btMakeDirdata.Image")));
this.btMakeDirdata.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btMakeDirdata.Name = "btMakeDirdata";
this.btMakeDirdata.Size = new System.Drawing.Size(69, 22);
this.btMakeDirdata.Text = "Remake";
this.btMakeDirdata.Click += new System.EventHandler(this.toolStripButton3_Click);
//
// toolStripButton2
//
this.toolStripButton2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton2.Name = "toolStripButton2";
this.toolStripButton2.Size = new System.Drawing.Size(54, 22);
this.toolStripButton2.Text = "Clear";
this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
//
// tabPage3
//
this.tabPage3.Controls.Add(this.lstMagnet);
this.tabPage3.Controls.Add(this.toolStrip5);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(292, 309);
this.tabPage3.TabIndex = 3;
this.tabPage3.Text = "마그넷라인";
this.tabPage3.UseVisualStyleBackColor = true;
//
// lstMagnet
//
this.lstMagnet.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstMagnet.FormattingEnabled = true;
this.lstMagnet.ItemHeight = 12;
this.lstMagnet.Location = new System.Drawing.Point(0, 25);
this.lstMagnet.Name = "lstMagnet";
this.lstMagnet.Size = new System.Drawing.Size(292, 284);
this.lstMagnet.TabIndex = 2;
//
// toolStrip5
//
this.toolStrip5.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btDelMagnet,
this.toolStripButton3});
this.toolStrip5.Location = new System.Drawing.Point(0, 0);
this.toolStrip5.Name = "toolStrip5";
this.toolStrip5.Size = new System.Drawing.Size(292, 25);
this.toolStrip5.TabIndex = 6;
this.toolStrip5.Text = "toolStrip5";
//
// btDelMagnet
//
this.btDelMagnet.Image = ((System.Drawing.Image)(resources.GetObject("btDelMagnet.Image")));
this.btDelMagnet.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btDelMagnet.Name = "btDelMagnet";
this.btDelMagnet.Size = new System.Drawing.Size(61, 22);
this.btDelMagnet.Text = "Delete";
this.btDelMagnet.Click += new System.EventHandler(this.btDelMagnet_Click);
//
// _propertyGrid
//
this._propertyGrid.Dock = System.Windows.Forms.DockStyle.Bottom;
@@ -226,11 +412,12 @@ namespace AGVMapEditor.Forms
this.btnDelete,
this.btnEditImage,
this.separator1,
this.btnConnect,
this.btnDeleteConnection,
this.btnConnNode,
this.btnConnDir,
this.toolStripSeparator1,
this.btnToggleGrid,
this.btnFitMap});
this.btnFitMap,
this.btAddMagnet});
this.toolStrip3.Location = new System.Drawing.Point(0, 0);
this.toolStrip3.Name = "toolStrip3";
this.toolStrip3.Size = new System.Drawing.Size(896, 25);
@@ -264,6 +451,8 @@ namespace AGVMapEditor.Forms
this.btnAddNode.Size = new System.Drawing.Size(111, 22);
this.btnAddNode.Text = "노드 추가 (A)";
this.btnAddNode.ToolTipText = "노드 추가 (A)";
this.btnAddNode.ButtonClick += new System.EventHandler(this.btnAddNode_ButtonClick);
this.btnAddNode.BackColorChanged += new System.EventHandler(this.btnAddNode_BackColorChanged);
//
// btnAddLabel
//
@@ -308,21 +497,20 @@ namespace AGVMapEditor.Forms
this.separator1.Name = "separator1";
this.separator1.Size = new System.Drawing.Size(6, 25);
//
// btnConnect
// btnConnNode
//
this.btnConnect.Image = ((System.Drawing.Image)(resources.GetObject("btnConnect.Image")));
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(95, 22);
this.btnConnect.Text = "노드연결 (C)";
this.btnConnNode.Image = ((System.Drawing.Image)(resources.GetObject("btnConnNode.Image")));
this.btnConnNode.Name = "btnConnNode";
this.btnConnNode.Size = new System.Drawing.Size(95, 22);
this.btnConnNode.Text = "노드연결 (C)";
//
// btnDeleteConnection
// btnConnDir
//
this.btnDeleteConnection.Image = ((System.Drawing.Image)(resources.GetObject("btnDeleteConnection.Image")));
this.btnDeleteConnection.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnDeleteConnection.Name = "btnDeleteConnection";
this.btnDeleteConnection.Size = new System.Drawing.Size(94, 22);
this.btnDeleteConnection.Text = "연결삭제 (X)";
this.btnDeleteConnection.ToolTipText = "연결 삭제 (X)";
this.btnConnDir.Image = ((System.Drawing.Image)(resources.GetObject("btnConnDir.Image")));
this.btnConnDir.Name = "btnConnDir";
this.btnConnDir.Size = new System.Drawing.Size(95, 22);
this.btnConnDir.Text = "방향연결 (C)";
this.btnConnDir.Click += new System.EventHandler(this.btnConnDir_Click);
//
// toolStripSeparator1
//
@@ -345,6 +533,15 @@ namespace AGVMapEditor.Forms
this.btnFitMap.Text = "맵 맞춤";
this.btnFitMap.ToolTipText = "맵 전체 보기";
//
// btAddMagnet
//
this.btAddMagnet.Image = ((System.Drawing.Image)(resources.GetObject("btAddMagnet.Image")));
this.btAddMagnet.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btAddMagnet.Name = "btAddMagnet";
this.btAddMagnet.Size = new System.Drawing.Size(87, 22);
this.btAddMagnet.Text = "마그넷추가";
this.btAddMagnet.Click += new System.EventHandler(this.btAddMagnet_Click);
//
// toolStrip2
//
this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -444,6 +641,16 @@ namespace AGVMapEditor.Forms
this.allTurnLeftRightCrossOnToolStripMenuItem.Text = "All TurnLeft/Right/Cross On";
this.allTurnLeftRightCrossOnToolStripMenuItem.Click += new System.EventHandler(this.allTurnLeftRightCrossOnToolStripMenuItem_Click);
//
// toolStripButton3
//
this.toolStripButton3.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton3.Name = "toolStripButton3";
this.toolStripButton3.Size = new System.Drawing.Size(66, 22);
this.toolStripButton3.Text = "Refresh";
this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click_1);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -471,6 +678,15 @@ namespace AGVMapEditor.Forms
this.tabPage1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.toolStrip4.ResumeLayout(false);
this.toolStrip4.PerformLayout();
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
this.toolStrip5.ResumeLayout(false);
this.toolStrip5.PerformLayout();
this.toolStrip3.ResumeLayout(false);
this.toolStrip3.PerformLayout();
this.toolStrip2.ResumeLayout(false);
@@ -506,9 +722,8 @@ namespace AGVMapEditor.Forms
private System.Windows.Forms.ToolStripButton btnSelect;
private System.Windows.Forms.ToolStripButton btnMove;
private System.Windows.Forms.ToolStripButton btnEditImage;
private System.Windows.Forms.ToolStripButton btnConnect;
private System.Windows.Forms.ToolStripButton btnConnNode;
private System.Windows.Forms.ToolStripButton btnDelete;
private System.Windows.Forms.ToolStripButton btnDeleteConnection;
private System.Windows.Forms.ToolStripSeparator separator1;
private System.Windows.Forms.ToolStripButton btnToggleGrid;
private System.Windows.Forms.ToolStripButton btnFitMap;
@@ -520,5 +735,23 @@ namespace AGVMapEditor.Forms
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripDropDownButton toolStripButton1;
private System.Windows.Forms.ToolStripMenuItem allTurnLeftRightCrossOnToolStripMenuItem;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.ListBox lstMagnetDirection;
private System.Windows.Forms.ToolStrip toolStrip4;
private System.Windows.Forms.ToolStripButton btDirDelete;
private System.Windows.Forms.ToolStripButton btMakeDirdata;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ToolStripButton btAddMagnet;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.ListBox lstMagnet;
private System.Windows.Forms.ToolStrip toolStrip5;
private System.Windows.Forms.ToolStripButton btDelMagnet;
private System.Windows.Forms.ToolStripStatusLabel sbFile;
private System.Windows.Forms.ToolStripButton btnConnDir;
private System.Windows.Forms.ToolStripButton toolStripButton3;
}
}

View File

@@ -10,6 +10,7 @@ using AGVNavigationCore.Models;
using MapImage = AGVNavigationCore.Models.MapImage;
using MapLabel = AGVNavigationCore.Models.MapLabel;
using Newtonsoft.Json;
using System.ComponentModel;
namespace AGVMapEditor.Forms
{
@@ -43,8 +44,8 @@ namespace AGVMapEditor.Forms
public override string ToString()
{
// RFID가 있으면 RFID(노드이름), 없으면 NodeID(노드이름) 형태로 표시
string fromDisplay = FromRfidId > 0
? $"{FromRfidId:0000}(*{FromNodeId.PadLeft(4,'0')})"
string fromDisplay = FromRfidId > 0
? $"{FromRfidId:0000}(*{FromNodeId.PadLeft(4, '0')})"
: $"(*{FromNodeId})";
string toDisplay = ToRfidId > 0
@@ -58,6 +59,7 @@ namespace AGVMapEditor.Forms
}
#endregion
#region Constructor
@@ -105,6 +107,7 @@ namespace AGVMapEditor.Forms
{
_mapCanvas = new UnifiedAGVCanvas();
_mapCanvas.Dock = DockStyle.Fill;
_mapCanvas.Mode = UnifiedAGVCanvas.CanvasMode.Edit;
// 이벤트 연결
_mapCanvas.NodeAdded += OnNodeAdded;
@@ -112,6 +115,7 @@ namespace AGVMapEditor.Forms
_mapCanvas.NodesSelected += OnNodesSelected; // 다중 선택 이벤트
_mapCanvas.NodeMoved += OnNodeMoved;
_mapCanvas.NodeDeleted += OnNodeDeleted;
_mapCanvas.ConnectionCreated += OnConnectionCreated;
_mapCanvas.ConnectionDeleted += OnConnectionDeleted;
_mapCanvas.ImageDoubleClicked += OnImageDoubleClicked;
_mapCanvas.MapChanged += OnMapChanged;
@@ -141,9 +145,8 @@ namespace AGVMapEditor.Forms
btnAddLabel.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.AddLabel;
btnAddImage.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.AddImage;
btnConnect.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.Connect;
btnConnNode.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.Connect;
btnDelete.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.Delete;
btnDeleteConnection.Click += (s, e) => _mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.DeleteConnection;
// 그리드 토글 버튼
btnToggleGrid.Click += (s, e) => _mapCanvas.ShowGrid = !_mapCanvas.ShowGrid;
@@ -179,6 +182,7 @@ namespace AGVMapEditor.Forms
_hasChanges = true;
UpdateTitle();
RefreshNodeList();
RefreshMagnetList(); // 추가
// RFID 자동 할당
}
@@ -212,6 +216,20 @@ namespace AGVMapEditor.Forms
{
// 단일 선택은 기존 방식 사용
_selectedNode = nodes[0];
// Sync with lstMagnet
if (_selectedNode is MapMagnet magnet)
{
lstMagnet.SelectedItem = magnet;
}
else
{
lstMagnet.SelectedItem = null;
}
//this._mapCanvas.SelectedNode = nodes;
//this._mapCanvas.Invalidate();
UpdateNodeProperties();
UpdateImageEditButton();
}
@@ -239,17 +257,20 @@ namespace AGVMapEditor.Forms
_hasChanges = true;
UpdateTitle();
RefreshNodeList();
RefreshMagnetList(); // 추가
ClearNodeProperties();
// RFID 자동 할당
}
private void OnConnectionCreated(object sender, (MapNode From, MapNode To) connection)
{
_hasChanges = true;
UpdateTitle();
RefreshNodeConnectionList();
UpdateNodeProperties(); // 연결 정보 업데이트
}
private void OnConnectionDeleted(object sender, (MapNode From, MapNode To) connection)
{
_hasChanges = true;
@@ -258,6 +279,8 @@ namespace AGVMapEditor.Forms
UpdateNodeProperties(); // 연결 정보 업데이트
}
private void OnImageDoubleClicked(object sender, MapImage image)
{
// 이미지 노드 더블클릭 시 이미지 편집창 표시
@@ -277,6 +300,7 @@ namespace AGVMapEditor.Forms
{
_hasChanges = true;
UpdateTitle();
RefreshMagnetDirectionList(); // 방향 정보 업데이트
}
private void OnBackgroundClicked(object sender, Point location)
@@ -400,7 +424,7 @@ namespace AGVMapEditor.Forms
var nodeId = GenerateNodeId();
var position = new Point(100 + this._mapCanvas.Nodes.Count * 50, 100 + this._mapCanvas.Nodes.Count * 50);
var node = new MapNode(nodeId, position, StationType.Normal);
var node = new MapNode(nodeId, position, Station.Normal);
this._mapCanvas.Nodes.Add(node);
_hasChanges = true;
@@ -618,7 +642,7 @@ namespace AGVMapEditor.Forms
private void LoadMapFromFile(string filePath)
{
var result = MapLoader.LoadMapFromFile(filePath);
sbFile.Text = filePath;
if (result.Success)
{
// 맵 캔버스에 데이터 설정
@@ -634,6 +658,7 @@ namespace AGVMapEditor.Forms
UpdateTitle();
UpdateNodeList();
RefreshNodeConnectionList();
RefreshMagnetList(); // 추가
@@ -764,6 +789,7 @@ namespace AGVMapEditor.Forms
{
RefreshNodeList();
RefreshNodeConnectionList();
RefreshMagnetList(); // 추가
RefreshMapCanvas();
ClearNodeProperties();
}
@@ -771,7 +797,7 @@ namespace AGVMapEditor.Forms
private void RefreshNodeList()
{
listBoxNodes.DataSource = null;
listBoxNodes.DataSource = this._mapCanvas.Nodes;
listBoxNodes.DataSource = this._mapCanvas.Items;
listBoxNodes.DisplayMember = "DisplayText";
listBoxNodes.ValueMember = "Id";
@@ -787,7 +813,7 @@ namespace AGVMapEditor.Forms
private void ListBoxNodes_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBoxNodes.SelectedItem is MapNode selectedNode)
if (listBoxNodes.SelectedItem is NodeBase selectedNode)
{
_selectedNode = selectedNode;
UpdateNodeProperties();
@@ -824,9 +850,9 @@ namespace AGVMapEditor.Forms
case NodeType.Normal:
var item = node as MapNode;
if (item.StationType == StationType.Normal)
if (item.StationType == Station.Normal)
foreColor = Color.DimGray;
else if (item.StationType == StationType.Charger1 || item.StationType == StationType.Charger2)
else if (item.StationType == Station.Charger)
foreColor = Color.Red;
else
foreColor = Color.DarkGreen;
@@ -942,13 +968,21 @@ namespace AGVMapEditor.Forms
_mapCanvas?.HighlightConnection(connectionInfo.FromNodeId, connectionInfo.ToNodeId);
// 연결된 노드들을 맵에서 하이라이트 표시 (선택적)
var fromNode = this._mapCanvas.Nodes.FirstOrDefault(n => n.Id == connectionInfo.FromNodeId);
if (fromNode != null)
{
_selectedNode = fromNode;
UpdateNodeProperties();
_mapCanvas?.Invalidate();
}
//var fromNode = this._mapCanvas.Nodes.FirstOrDefault(n => n.Id == connectionInfo.FromNodeId);
//if (fromNode != null)
//{
// if (_selectedNode != fromNode)
// {
// _selectedNode = fromNode;
// _mapCanvas.SelectedNode = fromNode; // 캔버스 선택 상태 동기화
// // 속성창 업데이트 (리스트 리프레시 포함)
// // 주의: RefreshMagnetDirectionList()가 호출되어도 lstNodeConnection에는 영향이 없으므로 안전함
// UpdateNodeProperties();
// _mapCanvas?.Invalidate();
// }
//}
}
else
{
@@ -981,6 +1015,9 @@ namespace AGVMapEditor.Forms
// 이미지 노드인 경우 편집 버튼 활성화
UpdateImageEditButton();
// 마그넷 방향 리스트 업데이트
RefreshMagnetDirectionList();
}
/// <summary>
@@ -996,6 +1033,7 @@ namespace AGVMapEditor.Forms
{
_propertyGrid.SelectedObject = null;
DisableImageEditButton();
lstMagnetDirection.DataSource = null;
}
/// <summary>
@@ -1101,6 +1139,13 @@ namespace AGVMapEditor.Forms
// 변경된 속성명 디버그 출력
System.Diagnostics.Debug.WriteLine($"[PropertyGrid] 속성 변경됨: {e.ChangedItem.PropertyDescriptor.Name}");
// 🔥 MagnetDirectionInfo 변경 처리
if (_propertyGrid.SelectedObject is MagnetDirectionInfo magInfo)
{
ApplyDirectionChange(magInfo);
return;
}
// RFID 값 변경시 중복 검사
if (e.ChangedItem.PropertyDescriptor.Name == "RFID")
{
@@ -1289,9 +1334,9 @@ namespace AGVMapEditor.Forms
{
foreach (var node in this._mapCanvas.Nodes)
{
node.CanTurnLeft = true;
node.CanTurnRight = true;
node.DisableCross = false;
node.CanTurnLeft = false;
node.CanTurnRight = false;
node.DisableCross = true;
node.ModifiedDate = DateTime.Now;
}
@@ -1308,5 +1353,560 @@ namespace AGVMapEditor.Forms
UpdateStatusBar($"모든 노드의 회전/교차 속성 활성화 완료");
}
}
/// <summary>
/// 마그넷 방향 정보를 표현하는 클래스
/// </summary>
public class MagnetDirectionInfo
{
[JsonIgnore, Browsable(false)]
public MapNode FromNode { get; set; }
[JsonIgnore, Browsable(false)]
public MapNode ToNode { get; set; }
[Category("연결 정보")]
[DisplayName("출발 노드")]
[Description("출발 노드의 ID입니다.")]
[ReadOnly(true)]
public string FromNodeId => FromNode?.ID2 ?? "Unknown";
[Category("연결 정보")]
[DisplayName("도착 노드")]
[Description("도착 노드의 ID입니다.")]
[ReadOnly(true)]
public string ToNodeId => ToNode?.ID2 ?? "Unknown";
[Category("설정")]
[DisplayName("방향")]
[Description("이동할 마그넷 방향입니다.")]
public MagnetPosition? Direction { get; set; }
public override string ToString()
{
string dirStr = Direction.HasValue ? Direction.Value.ToString() : "None";
string fromStr = FromNode != null ? FromNode.ID2 : "Unknown";
string toStr = ToNode != null ? ToNode.ID2 : "Unknown";
return $"{fromStr} -> {toStr} : {dirStr}";
}
}
private void RefreshMagnetDirectionList()
{
// 이벤트 임시 제거 (DataSource 변경 시 불필요한 이벤트 발생 방지)
lstMagnetDirection.SelectedIndexChanged -= LstMagnetDirection_SelectedIndexChanged;
// 현재 선택된 항목 기억
int selectedIndex = lstMagnetDirection.SelectedIndex;
// 데이터 소스 초기화 (UI 갱신 강제)
lstMagnetDirection.DataSource = null;
lstMagnetDirection.Items.Clear();
if (this._mapCanvas.Nodes == null)
{
// 이벤트 다시 연결 (빠른 리턴 시에도 연결 필요)
lstMagnetDirection.SelectedIndexChanged += LstMagnetDirection_SelectedIndexChanged;
return;
}
var directions = new List<MagnetDirectionInfo>();
// 모든 노드 검색
foreach (var nodeItem in this._mapCanvas.Nodes)
{
if (nodeItem is MapNode node)
{
if (node.MagnetDirections != null && node.MagnetDirections.Count > 0)
{
foreach (var kvp in node.MagnetDirections)
{
var neighborId = kvp.Key;
var dir = kvp.Value;
var neighbor = this._mapCanvas.Nodes.FirstOrDefault(t => t.Id == neighborId);
directions.Add(new MagnetDirectionInfo
{
FromNode = node,
ToNode = neighbor,
Direction = dir
});
}
}
}
}
// 보기 좋게 정렬 (FromNode ID 순)
directions.Sort((a, b) => string.Compare(a.FromNode.Id, b.FromNode.Id));
if (directions.Count > 0)
{
lstMagnetDirection.DataSource = directions;
}
// 이벤트 다시 연결
lstMagnetDirection.SelectedIndexChanged += LstMagnetDirection_SelectedIndexChanged;
lstMagnetDirection.DoubleClick -= LstMagnetDirection_DoubleClick;
lstMagnetDirection.DoubleClick += LstMagnetDirection_DoubleClick;
// 선택 항목 복원 (가능한 경우) -> 선택된 객체가 다르게 생성되므로 인덱스로 복원 시도
if (selectedIndex >= 0 && selectedIndex < lstMagnetDirection.Items.Count)
{
try
{
lstMagnetDirection.SelectedIndex = selectedIndex;
}
catch (Exception ex)
{
}
}
}
private void LstMagnetDirection_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
// 버튼 상태 업데이트
UpdateDirectionButtons(info);
// 캔버스에서 해당 연결선 강조 표시
if (info.FromNode != null && info.ToNode != null)
{
_mapCanvas.HighlightConnection(info.FromNode.Id, info.ToNode.Id);
// FromNode 선택 (속성창 갱신 루프 방지 위해 _propertyGrid 직접 설정 고려)
// 하지만 _selectedNode 변경 시 RefreshMagnetDirectionList()가 호출되어 리스트가 재생성되면 선택이 풀릴 수 있음
// 따라서 여기서는 캔버스 상의 선택 표시만 변경하고, 전체 속성 업데이트(리스트 리프레시 포함)는 건너뛰거나
// 리스트 리프레시 로직에서 선택 상태 유지를 보완해야 함.
// 일단 _selectedNode를 변경하되, RefreshMagnetDirectionList에서 선택 인덱스 복원을 하므로 괜찮을 것으로 예상됨.
// 만약 깜빡임이나 끊김이 심하면 UpdateNodeProperties 내의 RefreshMagnetDirectionList 호출을 조건부로 변경해야 함.
if (_selectedNode != info.FromNode)
{
var prevSelected = _selectedNode;
_selectedNode = info.FromNode;
// _mapCanvas.SelectedNode 설정 (이것만으로는 PropertyGrid 갱신 안됨)
_mapCanvas.SelectedNode = info.FromNode;
// PropertyGrid 갱신 (리스트 리프레시 포함)
// 주의: 여기서 UpdateNodeProperties()를 부르면 리스트가 다시 그려지면서 선택 이벤트가 다시 발생할 수 있음.
// 하지만 인덱스 복원 로직이 있으므로 무한루프는 아닐 수 있으나, 비효율적임.
// 해결책: 리스트 리프레시 없이 속성창만 갱신
_propertyGrid.SelectedObject = _selectedNode;
UpdateImageEditButton();
// 캔버스 다시 그리기
_mapCanvas.Invalidate();
}
}
}
else
{
_mapCanvas.ClearHighlightedConnection();
}
}
private void LstMagnetDirection_DoubleClick(object sender, EventArgs e)
{
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
var node = info.FromNode;
if (node != null)
{
// 방향 순환
if (info.Direction == MagnetPosition.S) info.Direction = MagnetPosition.L;
else if (info.Direction == MagnetPosition.L) info.Direction = MagnetPosition.R;
else if (info.Direction == MagnetPosition.R) info.Direction = MagnetPosition.S;
ApplyDirectionChange(info);
}
}
}
private void ApplyDirectionChange(MagnetDirectionInfo info)
{
var node = info.FromNode;
if (node == null) return;
// 딕셔너리 업데이트
if (node.MagnetDirections == null)
node.MagnetDirections = new Dictionary<string, MagnetPosition>();
if (info.ToNode != null)
{
if (info.Direction == null)
{
if (node.MagnetDirections.ContainsKey(info.ToNode.Id))
node.MagnetDirections.Remove(info.ToNode.Id);
}
else
{
node.MagnetDirections[info.ToNode.Id] = info.Direction.Value;
}
_hasChanges = true;
UpdateTitle();
// 리스트 갱신
RefreshMagnetDirectionList();
// 캔버스 등 갱신
_mapCanvas.Invalidate();
// 속성창 갱신 (선택된 객체가 바뀌었을 수 있으므로 다시 설정은 RefreshMagnetDirectionList의 선택 복원에서 처리됨)
_propertyGrid.Refresh();
}
}
private void btMakeDirdata_Click(object sender, EventArgs e)
{
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
if (this._mapCanvas.Nodes == null || this._mapCanvas.Nodes.Count == 0)
return;
// 기존 목록을 모두 지울지 물어보고
var result = MessageBox.Show(
"마그넷방향을 자동 생성할까요? 없는 부분만 추가됩니다.",
"마그넷 방향 자동 생성",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result != DialogResult.Yes)
return;
bool clearAll = false;// (result == DialogResult.Yes);
int updateCount = 0;
foreach (var node in this._mapCanvas.Nodes)
{
// 연결 노드가 3개 이상인 노드들을 찾아서
if (node.Type == NodeType.Normal && node is MapNode mapNode)
{
if (clearAll)
{
if (mapNode.MagnetDirections != null)
mapNode.MagnetDirections.Clear();
else mapNode.MagnetDirections = new Dictionary<string, MagnetPosition>();
}
if (mapNode.ConnectedNodes.Count >= 3)
{
// 마그넷 방향 딕셔너리가 없으면 생성
if (mapNode.MagnetDirections == null)
mapNode.MagnetDirections = new Dictionary<string, MagnetPosition>();
foreach (var connectedId in mapNode.ConnectedNodes)
{
// 이미 설정된 경우 건너뜀 (모두 초기화 안 한 경우)
if (!clearAll && mapNode.MagnetDirections.ContainsKey(connectedId))
continue;
// 모두 자동 생성을 해준다 (기본은 직진으로)
mapNode.MagnetDirections[connectedId] = MagnetPosition.S;
updateCount++;
}
}
}
}
if (updateCount > 0)
{
_hasChanges = true;
UpdateTitle();
// 현재 선택된 노드의 속성창 및 리스트 갱신
UpdateNodeProperties();
MessageBox.Show($"총 {updateCount}개의 연결에 대해 마그넷 방향(직진)이 설정되었습니다.", "완료", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("변경된 사항이 없습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btDirDelete_Click(object sender, EventArgs e)
{
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
// 선택된 방향정보를 삭제한다.
var result = MessageBox.Show(
$"선택한 마그넷 방향 정보를 삭제하시겠습니까?\n{info.FromNodeId} -> {info.ToNodeId} : {info.Direction}",
"삭제 확인",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (info.FromNode != null && info.FromNode.MagnetDirections != null)
{
if (info.ToNode != null && info.FromNode.MagnetDirections.ContainsKey(info.ToNode.Id))
{
info.FromNode.MagnetDirections.Remove(info.ToNode.Id);
_hasChanges = true;
UpdateTitle();
// 리스트 및 UI 갱신
RefreshMagnetDirectionList();
// 캔버스 갱신
_mapCanvas.Invalidate();
}
}
}
}
else
{
MessageBox.Show("삭제할 항목을 선택해주세요.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button1_Click(object sender, EventArgs e)
{
//set left
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
info.Direction = MagnetPosition.L;
ApplyDirectionChange(info);
UpdateDirectionButtons(info);
}
}
private void button2_Click(object sender, EventArgs e)
{
//set straight
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
info.Direction = MagnetPosition.S;
ApplyDirectionChange(info);
UpdateDirectionButtons(info);
}
}
private void button3_Click(object sender, EventArgs e)
{
//set right
if (lstMagnetDirection.SelectedItem is MagnetDirectionInfo info)
{
info.Direction = MagnetPosition.R;
ApplyDirectionChange(info);
UpdateDirectionButtons(info);
}
}
private void UpdateDirectionButtons(MagnetDirectionInfo info)
{
button1.BackColor = SystemColors.Control;
button2.BackColor = SystemColors.Control;
button3.BackColor = SystemColors.Control;
if (info.Direction == MagnetPosition.L) button1.BackColor = Color.Lime;
else if (info.Direction == MagnetPosition.S) button2.BackColor = Color.Lime;
else if (info.Direction == MagnetPosition.R) button3.BackColor = Color.Lime;
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(
"기존 설정된 마그넷 방향 정보를 모두 초기화하시겠습니까?",
"마그넷 방향 일괄 삭제",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question);
if (result == DialogResult.Cancel)
return;
bool clearAll = (result == DialogResult.Yes);
int updateCount = 0;
foreach (var node in this._mapCanvas.Nodes)
{
// 연결 노드가 3개 이상인 노드들을 찾아서
if (node.Type == NodeType.Normal && node is MapNode mapNode)
{
if (clearAll)
{
if (mapNode.MagnetDirections != null)
mapNode.MagnetDirections.Clear();
else mapNode.MagnetDirections = new Dictionary<string, MagnetPosition>();
}
}
}
// 현재 선택된 노드의 속성창 및 리스트 갱신
UpdateNodeProperties();
}
private void btAddMagnet_Click(object sender, EventArgs e)
{
// 마그넷 추가
var result = MessageBox.Show("곡선 마그넷(Bezier)을 추가하시겠습니까?\n(예: 베지어 곡선, 아니오: 직선, 취소: 중단)",
"마그넷 타입 선택", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Cancel) return;
bool isBezier = (result == DialogResult.Yes);
// 화면 중앙 좌표 계산 (World Coordinate)
float zoom = _mapCanvas.ZoomFactor;
PointF pan = _mapCanvas.PanOffset;
float worldCX = (_mapCanvas.Width / 2f) / zoom - pan.X;
float worldCY = (_mapCanvas.Height / 2f) / zoom - pan.Y;
// 고유 ID 생성
string id = _mapCanvas.GenerateUniqueNodeId();
var magnet = new MapMagnet { Id = id };
// 점 생성 시 정규화(Snap) 처리
int cx = (int)worldCX;
int cy = (int)worldCY;
magnet.StartPoint = new Point(cx - 50, cy);
magnet.EndPoint = new Point(cx + 50, cy);
if (isBezier)
{
magnet.ControlPoint = new MapMagnet.MagnetPoint { X = cx, Y = cy - 50 };
}
// 캔버스에 추가
_mapCanvas.Magnets.Add(magnet);
_hasChanges = true;
UpdateTitle();
RefreshMapCanvas();
RefreshNodeList();
RefreshMagnetList(); // 추가
// 추가된 마그넷 선택
//_mapCanvas.SelectedNode = magnet;
UpdateNodeProperties();
}
private void btDelMagnet_Click(object sender, EventArgs e)
{
//선택한 마그넷라인을 삭제 (삭제 후 맵에 바로 반영되도록 업데이트필요)
if (lstMagnet.SelectedItem is MapMagnet magnet)
{
_mapCanvas.RemoveMagnet(magnet);
RefreshMagnetList();
}
}
private void RefreshMagnetList()
{
lstMagnet.DataSource = null;
lstMagnet.Items.Clear();
if (_mapCanvas.Magnets != null && _mapCanvas.Magnets.Count > 0)
{
lstMagnet.DataSource = _mapCanvas.Magnets;
}
// 이벤트 연결
lstMagnet.SelectedIndexChanged -= LstMagnet_SelectedIndexChanged;
lstMagnet.SelectedIndexChanged += LstMagnet_SelectedIndexChanged;
lstMagnet.DoubleClick -= LstMagnet_DoubleClick;
lstMagnet.DoubleClick += LstMagnet_DoubleClick;
lstMagnet.DrawMode = DrawMode.OwnerDrawFixed;
lstMagnet.DrawItem -= LstMagnet_DrawItem;
lstMagnet.DrawItem += LstMagnet_DrawItem;
}
private void LstMagnet_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
if (e.Index >= 0 && e.Index < lstMagnet.Items.Count)
{
var magnet = lstMagnet.Items[e.Index] as MapMagnet;
if (magnet != null)
{
Brush brush = Brushes.Black;
if (magnet.ControlPoint != null) // Curve
{
brush = Brushes.Blue; // Curve는 파란색
}
// 선택된 항목은 흰색 글씨 (배경이 파란색이므로)
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
brush = Brushes.White;
}
e.Graphics.DrawString(magnet.ToString(), e.Font, brush, e.Bounds);
}
}
e.DrawFocusRectangle();
}
private void LstMagnet_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstMagnet.SelectedItem is MapMagnet magnet)
{
_mapCanvas.SelectedNode = magnet;
//UpdateNodeProperties(); // SelectedNode setter에서 Invalidate 호출됨
}
}
private void LstMagnet_DoubleClick(object sender, EventArgs e)
{
if (lstMagnet.SelectedItem is MapMagnet magnet)
{
_mapCanvas.PanTo(magnet.Position);
}
}
private void btnAddNode_ButtonClick(object sender, EventArgs e)
{
}
private void btnAddNode_BackColorChanged(object sender, EventArgs e)
{
}
private void btnDeleteConnection_Click(object sender, EventArgs e)
{
_mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.DeleteConnection;
}
private void btnConnDir_Click(object sender, EventArgs e)
{
//방향연결(노드연결과 유사), 두 노드간의 방향을 생성한다 기본값 straight
_mapCanvas.CurrentEditMode = UnifiedAGVCanvas.EditMode.ConnectDirection;
}
private void toolStripButton3_Click_1(object sender, EventArgs e)
{
RefreshMagnetList();
}
}
}

View File

@@ -123,8 +123,29 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>249, 17</value>
</metadata>
<metadata name="toolStrip4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
</metadata>
<metadata name="toolStrip5.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>123, 56</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btNodeRemove.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="btDelMagnet.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripButton3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
@@ -142,18 +163,84 @@
<metadata name="toolStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>462, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>249, 17</value>
</metadata>
<data name="btNodeRemove.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolStrip4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
</metadata>
<data name="btDirDelete.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<data name="btMakeDirdata.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripButton2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnSelect.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHrSURBVDhPldBLaBNBHMfx/0kUVBBJ0lxWPIhihBJKyAqS
pHkQIS+9hXg3RhQviicrITnmJqFnQQ8RqiamRqkhj6VCQtuIQaVQcxdq3d3s61Dy0w002KnU9nP67+x8
h2GIDmD0kT+mLk/fZNf3pQkznCrM3DFnZflSRG05euast7izcpM72GGqMP1ZFRw1tXm+qq9dg9LiHgwb
dnFYP51i9/6T0r4wp39Kwfh2F8bGI2irEYjvTmo/Gpbj7N4JpXNxShUcdbV1DvpaHMb3HNrP4uiVb2Cj
cQtadxbSh6OQ3tM82+6iNLk5rXcd7ecJGIaB0WiE1dcp6F9v41eNvmxV6QzbTMjtKYtct9Wi0Si63S50
XUe/30fjaQTG+n1IVRpKb4lnuzFtyc4Nl06VE4kE0uk0CoUCSqUSqvOzMNYfYnORtqVFWhEr9JhtJ+Lx
+DjmeR5+vx+xWAzqSgRy3Q65dgJbFeLYZmIndrvd8Pl8sFqt5pWfbL6hbalCl6Uy9cSXlGG7sWQyiXw+
P469Xi8sFgvMdblCV6RXVDNnvKAjPxfoKttSOBxGLpfbE+8QFyj09/cugUAA2WwWLpcLHo9nT7yvTCaD
wWAAp9OJUCh0uNhkHtDpdFAsFscPxv7/r2AweM+8ts1mO3z8x29OYwsb4/6fnQAAAABJRU5ErkJggg==
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHsSURBVDhPldBLaBNBHMfx/0kUVBBJ0lxWPIhihBJKyAqS
pHkQIS+9hXg3RhQviicrITnmJqFnQQ8RqiamRqkhj6VCQtuIQaVQc64H6+5mX4eSn26gwU6ltp/Tf2fn
OwxDdACjj/wxdXn6Jru+L02Y4VRh5o45K8uXImrL0TNnvcWdlZvcwQ5ThenPquCoqc3zVX3tGpQW92DY
sIvD+ukUu/eflPaFOf1TCsa3uzA2HkFbjUB8d1L70bAcZ/dOKJ2LU6rgqKutc9DX4jC+59B+FkevfAMb
jVvQurOQPhyF9J7m2XYXpcnNab3raD9PwDAMjEYjrL5OQf96G79q9GWrSmfYZkJuT1nkuq0WjUbR7Xah
6zr6/T4aTyMw1u9DqtJQeks8241pS3ZuuHSqnEgkkE6nUSgUUCqVUJ2fhbH+EJuLtC0t0opYocdsOxGP
x8cxz/Pw+/2IxWJQVyKQ63bItRPYqhDHNhM7sdvths/ng9VqNa/8ZPMNbUsVuiyVqSe+pAzbjSWTSeTz
+XHs9XphsVhgrssVuiK9opo54wUd+blAV9mWwuEwcrncnniHuEChv793CQQCyGazcLlc8Hg8e+J9ZTIZ
DAYDOJ1OhEKhw8Um84BOp4NisTh+MPb/fwWDwXvmtW022+HjP34DP4sLE797GZoAAAAASUVORK5CYII=
</value>
</data>
<data name="btnMove.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
@@ -169,83 +256,83 @@
YIGDKaeH7rEGFFd1IN1M4c5nAYIcIXLXvmW+uOKfXMvpRO9rFnzJi9lqBKPZYVCedzYsH6SQ2l+Eu2SD
bfNyWeHqqhbxahSCGIM2MwSKrYzDWboBx5sxIsP6yvTPH0lk3YoGI9lhaB8NQZO+gl8Dj7SN1tpAvgAA
AABJRU5ErkJggg==
</value>
</data>
<data name="btnAddNode.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHZSURBVDhPnZJda9NwFMb3JbxV/BaD4ufZjcwhejsdiqig
8+1u8w2vUprNrE3axDWmKW1aQ0rbtPaFUkra2paCotWU9YVHzh8SidMVfSCEnHOe33MgZ61araJSqaBc
LqNUKqFYLKJQKMCyLHqfW1sl27axXC5PPb1ej0F0XT8bQslkcByHJXc6HR9CNdM0z4bQyjRMafSdz+et
yWSC+XzO6gQ0DOPvEEr1BlOp1Ekmk3Gm0ylGX7pI2Yes1263kU6n/wyhZG/lxWIBMo+/fsKj6BbuHWxA
sw9Yr9VqQdM0SJIUhJim6Y7HYzY0m80w/NzFbvQK9t5t46V6C4+jWz6k2WwimUwGIblc7pJhGO5oNGJD
H50PuH+4gefHN/FGu4tX6u0ApNFoQJblICSbzYYURXGHwyEbqncLeChs4sXxjg/ZPdpEshRm/VqtBlEU
wXHcL4iu66FEIuEOBoNTkNfv7+CZdA1Pj65jvpixLeLxOCKRyAUfQFJVlUH6/b4PefD2Mp7ErmJf2cH3
H998M8dxFwNmT7IsMwhdIlvXsbCv3MD0xF1t9iSKYigWi7l0id4vJrMkSavNngRBWBcEwaUDq9fr/2b2
xPP8Os/z7n+ZPREkHA6f/73u6SfD/w8v3D5c0gAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnAddLabel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHISURBVDhPnZJfa9pgFMb7JXa7sW9RkH2y3awro5ddS3Et
u2vHRsRcBEw0iEHiYpSg+Hcm0blUtOocdOCWbEZ5xnnlTXFule2BEN7znuf3HJKz12630Wq10Gg0UK/X
UavVUK1WUalU6P1gb5eazSZWq9XWMxwOGUTX9fshlEyGwWDAkj3PiyBUsyzrfgiNTM2URudyuVyZz+cI
w5DVCWia5t8hlMobDcP4aRjGIAgCfL75DkOdsrt+v49CofBnCCXzkZfLJcj8ZRrg1aGLk6cO3mfWkF6v
h3w+D0VRNiGWZfmz2Yw1LRYLlhx/7uLyuI+3Zx7OD7sRxHVd5HK5TUipVHpimqY/na6b7PotS746+QTh
/HoL4jgOVFXdhBSLxZimaf5kMmFN3dZXxA8cvDm9g8QPXOjK+r7T6UCWZQiCcAfRdT2WzWb98Xi8BXkX
9/D6qIeLow8IwyWbIp1OI5lMPooAJE3TYplMxh+NRhHk7JmNixddXJ128W0eRGZBEB5vmLlUVWUQ2kT2
4Zq3uHz5ET+CcLeZS5blWCqV8mkT+S8ms6Iou81ckiTtS5Lk04LZtv1vZi5RFPdFUfT/y8xFkEQi8fD3
Otcvn84Wo7k6b1AAAAAASUVORK5CYII=
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHGSURBVDhPnZJfa9pgFMb7JXa7sm9RkH2y3awro5dbS3Et
u2vHRsRcBEw0gqJxGiUo/q1JdDYVnVoLLbglm1GecV55U5xbZXsghPe85/k9h+TstFotNJtN1Ot11Go1
VKtVVCoVlMtlej/Z2aZGo4HlcrnxDAYDBtE07XEIJZOh3++zZMdxAgjVDMN4HEIjUzOl0blUKpVnsxl8
32d1Auq6/ncIpfLGbDb7M5/P9z3Pw83X78irE3bX6/WQy+X+DKFkPvJisQCZbyce3h3YOHph4XNiBel2
u8hkMlAUZR1iGIY7nU5Z03w+Z8nhVzbO3/Tw8cTB6UEngNi2jVQqtQ4pFovPdV13J5NVk1m7Y8kXR1cQ
Tq83IJZlQVXVdUihUAglk0l3PB6zpk7zHuF9Cx+OHyDhfRuasrpvt9uQZRmCIDxANE0LJRIJdzQabUA+
hR28P+zi7PASvr9gU8TjcUSj0d0AQEqn0wwyHA4DyMlLE2evO7g47uDbzAvMgiA8WzNzqarKILSJ7MM1
7nD+9gt+eP52M5csy6FYLObSJvJfTGZFUbabuSRJ2pMkyaUFM03z38xcoijuiaLo/peZiyCRSOTp73Wu
X1R9FoLvbSO9AAAAAElFTkSuQmCC
</value>
</data>
<data name="btnAddImage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAG6SURBVDhPnZLditpQFIXnJXrb0rcYkD5YL4pMYS7bKaXM
O0TMRUp+ETM2EqMERY3BH0TE0ap4UQaZE/TksIZzhpPBOjPSLgghe+/1rQ3ZZ3Eco9frodvtotPpoN1u
o9Vqodls8vebs1OKogiMsaNnPp8LiOd5r0N4MjfMZjORPJ1OMwivhWH4OoSvzId5Gv9uNBrN7XYLSqmo
c2AQBC9DeKoc9H1/5/v+LEkS0D+/QWNb9CaTCarV6vMQnixXTtMU3Mzu1kitC6Q/P4LGluiNx2NUKhWY
pnkICcOQbDYbMbTf70VyaubB3C9gv76DWRcZZDQaoVwuH0Lq9fqHIAjIer1+hNy2RTK7uQKrXh9BhsMh
HMc5hNRqtZzrumS1Wj1CFhGokQe7+fYEMfOgkS76/X4fhmFAUZQniOd5uVKpRJbL5THE+wHmXOLeuARL
qdjCsiwUi8V3GYDLdd2cbdtksVhkkL3+Ccz+jKR8hR3ZZmZFUd4fmKUcxxEQfokCMu+Cul/Bdslps5Rh
GDld1wm/RPmLudk0zdNmKU3TzjVNI/zABoPBv5mlVFU9V1WV/JdZikMKhcLbv+tSD5T6HZWMaVplAAAA
AElFTkSuQmCC
</value>
</data>
<data name="btnAddNode.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHdSURBVDhPnZLda9NgFMb3T3ir+F8Min/PbmQO0VvdUEQF
nV93bk7xKqXZzNqkzbrGmJKmXUhpm9Z+UEpJW9tSULT6lvWDR94X3kicrugDIeSc8/yeAzkrlUoF5XIZ
pVIJxWIRhUIB+XwejuPQ94WVZXJdF4vF4szT7XYZxDCM8yE0mRo8z2PJ7Xbbh9CabdvnQ+jKdJim0e9c
LueMx2PMZjNWp0DLsv4Ooal80DTNU9M0vclkguGXDj64B6zXarWQTqf/DKHJfOX5fA5qHn39hCfRDTzY
X4Pu7rNes9mErutQFCUIsW2bjEYjNjSdTjH43MF29BpeJm9hT7uDp9ENH9JoNJBKpYKQbDZ7xbIsMhwO
2dBH7wQPD9awe7yJt/p9vNbuBiD1eh2qqgYhmUwmpGkaGQwGbKjWyeOxtI5Xx1s+ZPtwHalimPWr1Spk
WYYgCL8ghmGEkskk6ff7ZyBv3t/DC+UGnh/exGw+ZVvE43FEIpFLPoBK07RQIpEgvV7Phzx6dxXPYtex
c7SF7z+++WZBEC4HzFyqqjIIvUS2rudg5+g2JqdkuZlLluVQLBYj9BL5L6ZmRVGWm7kkSVqVJInQA6vV
av9m5hJFcVUURfJfZi4KCYfDF3+vc/0ED18PUDextaQAAAAASUVORK5CYII=
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAG3SURBVDhPnZLditpQFIXnJXrb0rcYkD5YL4pMYS7bKaX0
HSLmIiW/ghmNaJSgqDH4g4hYrYoXpUgT9OSwyj7DyWBtR9oFIWTvvb61IfsqiiIMBgP0+330ej10u110
Oh202216P7u6pDAMwTk/e5bLpYB4nvc0hJLJsFgsRPJ8Ps8gVAuC4GkIrUzDlEbfrVarvd/vwRgTdQL6
vv93CKXKwWq1eqjX64skScC+fwOLbNGbzWao1Wp/hlCyXDlNU5CZ/9gitW6QfnkNFlmiN51OUalUYJrm
KSQIgni324mh4/EoklMzD+6+A69+BLduMshkMkG5XD6FNJvNV77vx9vt9gHytSuS+f0deO3zGWQ8HsNx
nFNIo9HIlUqleLPZPEBWIZiRB7//8Agx82ChLvrD4RCGYUBRlEeI53k527bj9Xp9DvE+gTu3+GncgqdM
bGFZForF4osMQHJdV0BWq1UGOepvwO23SMp3OMT7zKwoyssTs5TjOAJClyggyz6Y+x78kFw2SxmGkdN1
PaZLlL+YzKZpXjZLaZp2rWlaTAc2Go3+zSylquq1qqrxf5mlCFIoFJ7/Xpf6BUmpHXRPK0SnAAAAAElF
TkSuQmCC
</value>
</data>
<data name="btnDelete.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGvSURBVDhP7Y89T1phGIZpgR/QqTiQ6NDZP+BgCiZd2jA0
sUNNBx0cjIMDtB3EycGGxY2Evmym7eBGhfgVeuB8cM7hcIDQGKSU7+NBYWlrEw23ed+oMUdr/QHeybW8
ea77fR6b7T4s0WjUQwgRCSG4I5VIJPLisoAQUlJVAc1mmdFqUfYZ7XaF0en8gGFUYRg/USiotKRxtcCs
Vkvg+RSSySSD4zikUimk02nwPA9RFCFJElRVZSXhcPjYUvAdkiQw0SplMhkoisJkXc/BNBvXC2q1PSiK
DEEQmEglWZaZlM1mkcvloOs6isUCut3W9YJ6vQxNU5lEf6OSpmlMzOfzUMKL+Db1BFseJ3ZfubE2//Lk
QsbOziYOD9s4OqJ00OsZ6PcPzjFR/vwBef8YjmMhDEpx/P60AHluFF8Cr8EK/kfM58KfWAhYfQ4EHgHL
I+iujOOr7zEuz7gtG08dg4G6jqvpB12g79bZG5Pw2hu/Pk4DQRf++m3o+W2ozdoRn7A3rbM3hpscWpLe
DJ+0AyMw3zlRmXmA7WeO0w3vw/fW2X+Gm3S/TXjsVbo23ehCPgMKrqo38mZYEwAAAABJRU5ErkJggg==
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVDhP7Y89S1thGIZToz+gk+kg4uDsH3CQJh0VB0EH
pUM7iDh1SNRBnRwqLkKGQvoGnKxDF0lV6gfxJOfk5JyT8xGJlDSmMV+nJ5osVguR3OV9MRKOae0P8IZr
eXmu+30eh+MpLMFg0E0IiRFC8J9kAoHAyH0BISSlKAIKhTSjWKR8Z5RKGUa5fAbTzMI0fyCZVGhJvrXA
ymZT4PkIwuEwg+M4RCIRRKNR8DyPWCwGURShKAor8fv9N7aCU4iiwES7FI/HIcsyk3Vdg2XlHxbkct8g
yxIEQWAilSRJYlIikYCmadB1HScnSVQqxYcF5+dpqKrCJPoblVRVZaJhGJA/LOJ4qh/77i4cTfRgY2as
3pRxePgVFxclXF5SyqhWTdRqP++wkP60CsM7iJvQGhqpXfzafAdpdgBbvkmwgscIjbpwHVoD1ocB33Ng
pQ+V90P4MtqN+zP+le2XnY2G8hmtqS25QN/ts22z53Hmrz6+AZZc+O11oOp1IDftxO4rZ8E+2zbc+Itl
8XVvveTrgzXfhczbZzjwdN7ueDoW7LN/DTfeM7fndmbp2nSjpvwHq8ip+rkEjbgAAAAASUVORK5CYII=
</value>
</data>
<data name="btnEditImage.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL4SURBVDhPfdLxU9N1HMdx/oN+7/qp7vzF6+qX7vqts9K0
vDKzjvIcepx1GZ3XpQ1HJGL6FRbjKwOBDfg2CKMNJRkChps6JB34hcEWWmGIgIODue/23faRI3x229US
znrdvX/6vD+Pz93n/c5R3MMVSrs6J7tUzdL8mHKsLtmpavazamXOP2noHJy/Fw4/1BMJEknxv7WoC+aj
cWrb/NEskH45rieo6ZqmoitAyfkfcNyw4hz9mtOBUqp9Zj5usvF5Yz/GxnEW4gLZNaJlgcpmVUvrteen
kXp6cQxZaRs7gH3oI2qv51Pn34e57yj76lsxKTeZ1x4DxJOC+p4ZSrpb+D5QSp1/Lyd/3oXZ9z7SlVws
vs/Iq/qG4uZfmdNSyK7h1YCWFNh7ZznsdvCtWow8YEC6/B5HvNv56uJ2JE8BBrkMpa2FW625/H7uGIHG
TQRq1hsyQDQhaLxwD8ndjdV3gsqBfEq872D66S0Oe3L58sdCapoPEvYa0ca6QJ8lOtaOr3zzXAa4rwuU
vjDW7lEKnQpS537KPXuR+vZQ5PoES1MBC6ESlqY7CV82kwqe5c87VxmxfShy0rOOxAUOz1wGqXIH+KLU
wHHLq0jmDTRUbSYSKmYldZXU7QIig59ysyWfgC130W/dti4DLMYEJuebGNu2cuD069iKXiCo7CD03Ubu
Bw+xIq6RnMhD3N1JfNxE6NTWhyOVG5/PfGKF44YWiQl8E5eyNRDsoP/cfsJDxr8vGxBTHxALFXG7/g0U
5YyenYIlA6RWAd5LZYxfOMhKyoeYzOfB3V1owUP8VvcaM1OTyM5HxljtUqci0RgxXRBLPGDE28Iv3SZG
e2Rm/O+SnNxJJFDIRMPbLM7+wUJmlQf/XWV7h1puax/uTy9HWnaWvQLxO9yy7cBrepKBui14jr+00qS4
9fR51Zlhzd6hyllgbY7uXre8dK2aJf9J/Mc20Jr3lN5rXP/c2r7/zLYXnxBS3jPLvSe2LPdVvHylq/DZ
p9f2PJq/AD40i0VffXQ/AAAAAElFTkSuQmCC
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALySURBVDhPhdLfT1tlHMdx/gPvjYnJLrxZjF7otZk63XRx
OjdFl7UxZBonZjFulhVxyNzOoFLOKAi0wLHDbdhuw9EOmNhuK0PWsQMHimwqk0FBIND1tKftM4Lsbdpo
sxF/fJLv1fN9Xk/yfL8Fim+oWvGq87JX1e3u/y/Zo+qus2pNwd9p7ry2MB2N3jNSKVJp8Z+1ZAgW4kka
Tg3E80D25aSRot4fpdqvUX7+W9zXHXhGvuCkVkFdyMb7rU4+bunD0jLOYlIge4f1PFDjVvWs3nA+itTd
g3vQQfvoPlyD79FwtYjG8B5svYfY03QCq3KDBf0fgGRa0NQ9Q3lXG6e0ChrDuzn24y5sobeQLhdiD32E
ufZLyo7/zLyeQfYOPQjoaYGrZ5aDPjdfq2XI/SakS2/weXAbn/2wDSlQjEmuRGlv4+aJQn49dxit5QW0
+vWmHBBPCVou/I7k68IROkpNfxHlwdexfr+Vg4FCPv2uhPrj+5kLWtBH/WDMEh89Tahq03wOuGMIlN45
HF0jlHgUpM69VAV2I/W+Q6n3A+ytxSyOlbMc7WTuko1M5Cx/3L7C8FfvioLsbGNJgTswn0NqfRqfVJg4
Yn8eybaB5tpNxMbKWM1cIXOrmNi1D7nRVoTmfHMp7Hj1sRywlBBYPa9gad/CvpMv4Sx9moiynbFvNnIn
coBVMUB6woyY3kly3IpWu+XecM3GJ3OfWO2+rscSgtDExXz1RzroO7eXuUHLX5dNiKm3SYyVcqvpZRTl
jJGfgj0HZB4AghcrGb+wn9VMCDFZxN3pXeiRA/zS+CIzU5PInvvGWOdVp2LxBAlDkEjdZTjYxk9dVka6
ZWbCO0hP7iSmlTDR/BpLs7+xuHaVXR1qlfP0UF92ObKyp/I5SN7mpnM7QevD9DduJnDkmdVWxWdkz+Uz
Q7qrQ5XzwNocMq9bWR6oYzl8jPDhDbjNjxg9lvVPrO3712x96iEhmR9d8R/dvNJb/exlf8nj69b23J8/
AbuKiwBr5ZOIAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnConnect.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="btnConnNode.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHrSURBVDhPY/j//z8DJRhDgFSMIUAqxhAgFcMZdnZ2
@@ -260,19 +347,19 @@
gg==
</value>
</data>
<data name="btnDeleteConnection.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="btnConnDir.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHxSURBVDhP7Y7Ni1JhGMVvXadgWrWzRdQsU5BcRW4cR72E
H8FtoS6iFinWKwn2MaPdheJikIEJvGCuElpcaKOtTKUMdNxEZBut1Z1BipAiDZrSJvPEM5CYOP9BB154
OOd3Di/H/ddEdrv9GGPsbiKR6OVyOUiS1GGMnWOMaSVJUsmjjBhi/ynrdLojTqdzI51Oo9vtQlVV1Go1
xOPxbUmS6q1Wa0heo9EAMcRSZzJgNBovhsPhr+12u+fz+Z4KgjAKBAKQZRmxWAx0k0eZoigdYqkzPbCR
TCYHsiwHXS7Xoslk+latVtFsNlGv15HP50EeZcQQS53JgMFguBEMBvuZTOaOKIoVi8WyJwgCRFHcf3ST
RxkxxFJnMqDX68+43e53qVSqryjKl0KhgGw2i0gkgmg0un+X1xleXDr1+/nKAp4Ii3uPlo/enwxwHMeb
zeazDodjx+/374ZCoQFj7KfH47ni9XqtDy5bhm9un8eguInx2zK+P76FVyHd6JlVc3N65ECVbLz6o7gJ
yG5g7TiwvoTPG8soWvjtWXauSiua8fh1AdPqx7Ugf5adq4qNf7/78BoQ12K4yqG3yqFznUfZzn+YZedq
y3si8fLq6V8f15bwKbYA1X8I1QuaUcl2+N4se6C2vCejFSu/Q9+mH/0t/wFGlxos/Pd5kgAAAABJRU5E
rkJggg==
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHrSURBVDhPY/j//z8DJRhDgFSMIUAqxhAgFcMZdnZ2
3FlZWaWtra3v5s2b97+mpuZhTk6OeU5OjkRNTc1dkBhIDqQGpBbFACMjIzYfH5+uiRMn/n/x4sX/u3fv
/j948OD/xsbGe9XV1Ydu3rz5AyR25MiR/yA1ILUgPXADDA0N/YqLiz9cvXr1XURExDZvb+8/qamp/ydN
mvS/srLyP4gNEgPJrVix4iFILUgPsgu6mpqavk+ePDnd39+fy97e/vPevXv/nzt37v+hQ4f+r1279j9I
DCQHUgNSC9IDN0BXVzczPT39/bRp00qCgoJ2Ojo6/nJzc/sfGBgIxiA2SAwkB1IDUgvSAzdAU1NT09fX
93pvb+/7VatWvV23bt3/6dOn/y8sLPxfUVEBZvcvbP1fODXmX1qf//+IJse/Lrm6E+EGqKmpMdvb2xt4
eXndT0lJ+ZKdnf09Ozv7Z3h4eFx4eLhzZm3cz8bVif+3XJn6/8KzXf/7d2f9D+/X/W+eLdmDEa/YcGy7
y/eNlyf833ht0n8Q6NmT+r9/TzrIgO8YirFhn2rD/9uuzAFrhoFNl6aCDMBUjA1b5kh/796V9L99VwJY
c/vOBNJcYJ4t2RLco/G/d1cK2GYQDeITHQZQQzrMsyU/gZwNpTtA4gBRO5Y8lpxI5AAAAABJRU5ErkJg
gg==
</value>
</data>
<data name="btnToggleGrid.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
@@ -287,18 +374,33 @@
<data name="btnFitMap.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKYSURBVDhPhZBfSFNRHMfvY0RPEfQSFD2tniKh9WBZmM5W
es02del1ii7LJAsjtG6pOCdZuiJLZg8TbFMzuiSKlm7m/LPU3XOWkUKF89xBK0ak51pBcDlx1L1cF33h
vBy+n+/v+/sxzIZm3flasatAAF3m6Ey3WZl2c4rfyUX97TmCv/WsNuaLK+jmLPBpUUTsLACzHef4gNOk
mXRkafztBt7vMIKJtpyIz55pUXNropPX4TybGML7wBI2ACRXQEkuD6KV9Dm0vNd3n7WN29mI965+cxPR
XSDQyYEQ1gCELwKEq6GErwNp9RpE8lUoyXkw9GPPWAsLPI16Qc0zwG2Oznbk8sEwzgIIV63DcuUGXA4k
XAaQfMLToOdfNaRH1Twz08UpAYdJAyX5UmxqbAXaCCJcSlsM1aRqvE16Rc0zb135Cj0YNVIQLMmXaZiI
8IW1PwmXBJGcQwM8Nt3mgElnXtT/2MCL0mraegtctgaHsQVIuBiilUJRwkcHb6bwQzdSN68w1WYQplqN
gB4KIjl7AyyB0koRhQHC7Lvwz139dSd/D1QlT6t5xmfP0E48yoy8aWFt4uKv3TAsH6eVIZKNQYQTKext
zvwz11tBvJXHyIuKRJM6gxltyrD47GzEc+cUGK7X8XRf+gark/nRe+nKfH81CQccZHGimYzUs+RlsXan
OoPx2vTa11a9MNSgi9JjjVhTlb7buuXhutPk02gj+fqhk3xbcJGPw7Wk13xEcccLiSfhShI31pJLQpN2
EnnfQZb8D8n0kyJiS9F87jufsFXtj6vnZYnciPUMWRi4ReYHasj4g2zSW3rw+zPj/m1q7z/VYznEufIT
yKvaNNJdqP3iMiXsUHv+q57iw9vbcw9YneakLbG/v5ifpNsR5bepAAAAAElFTkSuQmCC
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKXSURBVDhPhZBfSFNRHMfvY0RPEfQSFD2tngqh9WBZmVOX
ess23ZrzD7r+mGRhhKNbKs6JVq7IktnDBNvUjFaSuNTNnJtD3D1nGSlUOM8dtGJEeq4VBJcTR93LddEX
zsvh+/n+vr8fw2xo1lWi5PtK3aCvLDHdb5CCLr0UdBgToe5id6jzrDLpSynoMprg04o431sKZnvOcWGH
XhG0FypC3RouZNeCQFdx3G87bZJza6KT12GDlY/ifWAJawASa6Eg1kTQSv4cWt7rv89ap2xs3HdHvbkJ
7yp108nhKFYAhC8BhM1QwDeAsHodIvEaFEQDjP7YM9nBAm+r2i3nGeAqS8z26LhIDBcChOvXYbFuA64B
Aq4GSDzpbVFznpb8hJxnpvv0UtiuV0BBvJycmlyBNoIIX6AtPA0qha9dJcl5JuDUSfRg1EhBsCReoWE8
whfX/gRcFUFiMQ3wWjM3BwQdhkTosYbjhdWc9Ra4eg2OYRMQcCVEK+W8gI+O3MziPGZVihW6NO7pTi2g
h4JILNoAq6CwUkFhgDD7LvZz18um3N/D9Zkzcp7x2wqUgUds/G0Ha+UXf+2GMfE4rQyRqI0gnE7h0ba8
P3ODtcRXd4y8qE3XyzOYifYCk9/Gxr1tp8BYczZH96VvxJzJTdzNleZfm0ksbCeLgXtkvJklryqVO+UZ
jM+qVo5a1G5PiypBjzVuOSEN3c5eHmvKI58mWsnXD73k24KTfBxrJIOGI5IrVUgqua9mGCc7dCQatJH4
+x6yFHpIZp5UEGuW4vPQ+bStcn9KPa9ON45bzpCF4VtkfriBTD0oIoMXDn5/pt2/Te79pwZMh4zOkjTy
pjGH9Jcrvzj1aTvknv9qoPLw9m7dAYujLGNL8u8v3CKkjDkyCW0AAAAASUVORK5CYII=
</value>
</data>
<data name="btAddMagnet.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("26.02.10.0900")]
[assembly: AssemblyFileVersion("26.02.10.0900")]

View File

@@ -49,7 +49,7 @@
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\HMI\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -84,6 +84,7 @@
<Compile Include="Models\NodeBase.cs" />
<Compile Include="Models\MapLabel.cs" />
<Compile Include="Models\MapImage.cs" />
<Compile Include="PathFinding\Core\Utility.cs" />
<Compile Include="PathFinding\Planning\AGVPathfinder.cs" />
<Compile Include="PathFinding\Planning\DirectionChangePlanner.cs" />
<Compile Include="PathFinding\Planning\DirectionalPathfinder.cs" />
@@ -93,7 +94,7 @@
<Compile Include="PathFinding\Core\PathNode.cs" />
<Compile Include="PathFinding\Core\AStarPathfinder.cs" />
<Compile Include="PathFinding\Core\AGVPathResult.cs" />
<Compile Include="PathFinding\Planning\NodeMotorInfo.cs" />
<Compile Include="Models\NodeMotorInfo.cs" />
<Compile Include="Controls\UnifiedAGVCanvas.cs">
<SubType>UserControl</SubType>
</Compile>

View File

@@ -72,6 +72,9 @@ namespace AGVNavigationCore.Controls
DrawDragGhost(g);
}
// 마그넷 방향 텍스트 그리기 (노드 위에 표시)
DrawMagnetDirections(g);
// AGV 그리기
DrawAGVs(g);
@@ -79,7 +82,7 @@ namespace AGVNavigationCore.Controls
DrawNodeLabels(g);
DrawLabels(g); // 추가: 텍스트 라벨
}
finally
{
@@ -87,8 +90,8 @@ namespace AGVNavigationCore.Controls
}
// UI 정보 그리기 (변환 없이)
if (_showGrid)
DrawUIInfo(g);
//if (_showGrid)
DrawUIInfo(g);
// 동기화 화면 그리기 (변환 없이, 최상위)
if (_canvasMode == CanvasMode.Sync)
@@ -97,25 +100,276 @@ namespace AGVNavigationCore.Controls
}
//예측문자는 디버깅시에만 표시한다.
if (string.IsNullOrEmpty(PredictMessage) == false && System.Diagnostics.Debugger.IsAttached)
if (string.IsNullOrEmpty(PredictMessage) == false)
{
g.DrawString(this.PredictMessage, this.Font, Brushes.White, 10, 100);
}
DrawSystemMessage(g);
DrawAlertMessage(g);
DrawTagIgnoreMessage(g);
}
private void DrawMagnetDirections(Graphics g)
{
if (_nodes == null) return;
using (var font = new Font("Arial", 8, FontStyle.Bold))
using (var brushS = new SolidBrush(Color.Magenta))
using (var brushL = new SolidBrush(Color.Green))
using (var brushR = new SolidBrush(Color.Blue))
using (var brushBg = new SolidBrush(Color.FromArgb(180, 255, 255, 255)))
{
foreach (var node in _nodes)
{
if (node.MagnetDirections != null && node.MagnetDirections.Count > 0)
{
foreach (var kvp in node.MagnetDirections)
{
var targetId = kvp.Key;
var dir = kvp.Value;
var targetNode = _nodes.FirstOrDefault(n => n.Id == targetId);
if (targetNode != null)
{
// 방향 텍스트 위치 계산 (출발 -> 도착 벡터의 일정 거리 지점)
var start = node.Position;
var end = targetNode.Position;
var angle = Math.Atan2(end.Y - start.Y, end.X - start.X);
// 박스(텍스트) 중심 위치: 약 40px 거리
var boxDist = 40;
var boxX = start.X + boxDist * Math.Cos(angle);
var boxY = start.Y + boxDist * Math.Sin(angle);
string text = dir.ToString();
Color color = Color.Blue;
if (dir == MagnetPosition.L) color = Color.LimeGreen;
else if (dir == MagnetPosition.R) color = Color.Red;
// 화살표 및 텍스트 설정
using (var arrowBrush = new SolidBrush(color))
using (var arrowPen = new Pen(color, 2)) // 두께 약간 증가
using (var textBrush = new SolidBrush(color))
{
// 1. 화살표 그리기 (박스를 가로지르는 선)
// 시작점: 노드 근처 (25px)
// 끝점: 박스 너머 (55px)
var arrowStartDist = 25;
var arrowEndDist = 55;
var pStart = new PointF((float)(start.X + arrowStartDist * Math.Cos(angle)), (float)(start.Y + arrowStartDist * Math.Sin(angle)));
var pEnd = new PointF((float)(start.X + arrowEndDist * Math.Cos(angle)), (float)(start.Y + arrowEndDist * Math.Sin(angle)));
// 화살표 선 그리기
g.DrawLine(arrowPen, pStart, pEnd);
// 화살표 머리 그리기 (끝점에)
var arrowSize = 6;
var pHead1 = new PointF((float)(pEnd.X + arrowSize * Math.Cos(angle)), (float)(pEnd.Y + arrowSize * Math.Sin(angle))); // 뾰족한 끝
// 삼각형 머리 (채우기)
var pBackL = new PointF((float)(pEnd.X + arrowSize * Math.Cos(angle + 2.5)), (float)(pEnd.Y + arrowSize * Math.Sin(angle + 2.5)));
var pBackR = new PointF((float)(pEnd.X + arrowSize * Math.Cos(angle - 2.5)), (float)(pEnd.Y + arrowSize * Math.Sin(angle - 2.5)));
// pHead1이 가장 먼 쪽이 되도록 조정 (pEnd가 삼각형의 뒷부분 중심이 되도록)
// pEnd에서 시작해서 앞으로 나가는 삼각형
// pTip = pEnd + size * angle
// pBackL = pEnd + size/2 * angle_back_L (약간 뒤로)
// 현재 코드는 pEnd를 중심으로, pHead1이 앞, pBackL/R이 뒤... 가 아니라
// pHead1, pBackK, pBackR로 삼각형을 그림.
// pHead1이 팁.
g.FillPolygon(arrowBrush, new PointF[] { pHead1, pBackL, pBackR });
// 2. 텍스트 그리기 (화살표 위에 박스, 그 위에 텍스트)
var textSize = g.MeasureString(text, font);
var textPoint = new PointF((float)(boxX - textSize.Width / 2), (float)(boxY - textSize.Height / 2));
//편집모드에서만 글자를 표시한다.
if (Mode == CanvasMode.Edit)
{
// 텍스트 배경 (반투명 - 선이 은은하게 보이도록 투명도 조절하거나, 가독성을 위해 불투명하게 처리)
// 사용자가 "박스를 가로지르는" 느낌을 원했으므로 선이 보여야 함. 하지만 텍스트 가독성도 필요.
// 배경을 아주 옅게 (Alpha 100정도) 처리하여 선이 보이게 함.
using (var translucentBg = new SolidBrush(Color.FromArgb(120, 255, 255, 255)))
{
g.FillRectangle(translucentBg, textPoint.X - 1, textPoint.Y - 1, textSize.Width + 2, textSize.Height + 2);
}
g.DrawString(text, font, textBrush, textPoint);
}
}
}
}
}
}
}
}
void DrawSystemMessage(Graphics g)
{
if (!showalertsystem || String.IsNullOrEmpty(this._systemmesage)) return;
// 상단 중앙에 반투명 빨간색 배경 바 표시
int barHeight = 40;
int barWidth = Math.Min(600, this.Width - 40); // 최대 600px, 좌우 여백 20px
int barX = (this.Width - barWidth) / 2;
int barY = 20;
// 둥근 사각형 배경
using (var path = new GraphicsPath())
{
int radius = 10;
path.AddArc(barX, barY, radius * 2, radius * 2, 180, 90);
path.AddArc(barX + barWidth - radius * 2, barY, radius * 2, radius * 2, 270, 90);
path.AddArc(barX + barWidth - radius * 2, barY + barHeight - radius * 2, radius * 2, radius * 2, 0, 90);
path.AddArc(barX, barY + barHeight - radius * 2, radius * 2, radius * 2, 90, 90);
path.CloseFigure();
using (var brush = new SolidBrush(Color.FromArgb(200, 255, 69, 58))) // 진한 붉은색 (Apple Red 계열)
{
g.FillPath(brush, path);
}
using (var pen = new Pen(Color.FromArgb(255, 255, 255), 2))
{
g.DrawPath(pen, path);
}
}
// 텍스트 깜박임 효과 (배경은 유지하고 텍스트만 깜박임)
using (var font = new Font("Malgun Gothic", 12, FontStyle.Bold))
using (var brush = new SolidBrush(Color.White))
{
var textSize = g.MeasureString(_systemmesage, font);
g.DrawString(_systemmesage, font, brush,
barX + (barWidth - textSize.Width) / 2,
barY + (barHeight - textSize.Height) / 2);
}
// 경고 아이콘 그리기 (왼쪽)
// 간단한 느낌표 아이콘
int iconX = barX + 15;
int iconY = barY + barHeight / 2;
using (var brush = new SolidBrush(Color.White))
{
g.FillEllipse(brush, iconX - 2, iconY - 8, 4, 16); // body
g.FillEllipse(brush, iconX - 2, iconY + 10, 4, 4); // dot
}
}
void DrawAlertMessage(Graphics g)
{
if (showalert == false) return;
if (!showinfo || String.IsNullOrEmpty(this._infomessage)) return;
//상단에 경고 메세지를 추가한다
if (String.IsNullOrEmpty(this._alertmesage)) return;
// 상단 중앙에 반투명 빨간색 배경 바 표시
int barHeight = 40;
int barWidth = Math.Min(600, this.Width - 40); // 최대 600px, 좌우 여백 20px
int barX = (this.Width - barWidth) / 2;
int barY = 20+50;
// 둥근 사각형 배경
using (var path = new GraphicsPath())
{
int radius = 10;
path.AddArc(barX, barY, radius * 2, radius * 2, 180, 90);
path.AddArc(barX + barWidth - radius * 2, barY, radius * 2, radius * 2, 270, 90);
path.AddArc(barX + barWidth - radius * 2, barY + barHeight - radius * 2, radius * 2, radius * 2, 0, 90);
path.AddArc(barX, barY + barHeight - radius * 2, radius * 2, radius * 2, 90, 90);
path.CloseFigure();
using (var brush = new SolidBrush(Color.FromArgb(255, Color.Lime)))
{
g.FillPath(brush, path);
}
using (var pen = new Pen(Color.FromArgb(255, 255, 255), 2))
{
g.DrawPath(pen, path);
}
}
// 텍스트 깜박임 효과 (배경은 유지하고 텍스트만 깜박임)
using (var font = new Font("Malgun Gothic", 12, FontStyle.Bold))
using (var brush = new SolidBrush(Color.Black))
{
var textSize = g.MeasureString(_infomessage, font);
g.DrawString(_infomessage, font, brush,
barX + (barWidth - textSize.Width) / 2,
barY + (barHeight - textSize.Height) / 2);
}
// 경고 아이콘 그리기 (왼쪽)
// 간단한 느낌표 아이콘
int iconX = barX + 15;
int iconY = barY + barHeight / 2;
using (var brush = new SolidBrush(Color.Black))
{
g.FillEllipse(brush, iconX - 2, iconY - 8, 4, 16); // body
g.FillEllipse(brush, iconX - 2, iconY + 10, 4, 4); // dot
}
g.DrawString(this._alertmesage, this.Font, Brushes.Gold, 10, 10);
}
void DrawTagIgnoreMessage(Graphics g)
{
if (!showtagigreno || String.IsNullOrEmpty(this._tagignoreMessage)) return;
var ts = DateTime.Now - tagignoretime;
if (ts.TotalSeconds > 5) return;
// 상단 중앙에 반투명 빨간색 배경 바 표시
int barHeight = 40;
int barWidth = Math.Min(600, this.Width - 40); // 최대 600px, 좌우 여백 20px
int barX = (this.Width - barWidth) / 2;
int barY = this.Height - barHeight-20;
// 둥근 사각형 배경
using (var path = new GraphicsPath())
{
int radius = 10;
path.AddArc(barX, barY, radius * 2, radius * 2, 180, 90);
path.AddArc(barX + barWidth - radius * 2, barY, radius * 2, radius * 2, 270, 90);
path.AddArc(barX + barWidth - radius * 2, barY + barHeight - radius * 2, radius * 2, radius * 2, 0, 90);
path.AddArc(barX, barY + barHeight - radius * 2, radius * 2, radius * 2, 90, 90);
path.CloseFigure();
using (var brush = new SolidBrush(Color.FromArgb(255, Color.Violet)))
{
g.FillPath(brush, path);
}
using (var pen = new Pen(Color.FromArgb(255, 255, 255), 2))
{
g.DrawPath(pen, path);
}
}
// 텍스트 깜박임 효과 (배경은 유지하고 텍스트만 깜박임)
using (var font = new Font("Malgun Gothic", 12, FontStyle.Bold))
using (var brush = new SolidBrush(Color.Black))
{
var textSize = g.MeasureString(_tagignoreMessage, font);
g.DrawString(_tagignoreMessage, font, brush,
barX + (barWidth - textSize.Width) / 2,
barY + (barHeight - textSize.Height) / 2);
}
// 경고 아이콘 그리기 (왼쪽)
// 간단한 느낌표 아이콘
int iconX = barX + 15;
int iconY = barY + barHeight / 2;
using (var brush = new SolidBrush(Color.Black))
{
g.FillEllipse(brush, iconX - 2, iconY - 8, 4, 16); // body
g.FillEllipse(brush, iconX - 2, iconY + 10, 4, 4); // dot
}
}
private void DrawSyncScreen(Graphics g)
{
// 반투명 검은색 배경
@@ -228,11 +482,26 @@ namespace AGVNavigationCore.Controls
foreach (var targetNode in node.ConnectedMapNodes)
{
if (targetNode == null) continue;
// 강조된 연결은 나중에 그리기 위해 건너뜀
if (IsConnectionHighlighted(node.Id, targetNode.Id)) continue;
DrawConnection(g, node, targetNode);
}
}
}
// 1.1 강조된 연결 그리기 (항상 위에 표시되도록)
if (_highlightedConnection.HasValue)
{
var n1 = _nodes.FirstOrDefault(n => n.Id == _highlightedConnection.Value.FromNodeId);
var n2 = _nodes.FirstOrDefault(n => n.Id == _highlightedConnection.Value.ToNodeId);
if (n1 != null && n2 != null)
{
DrawConnection(g, n1, n2);
}
}
// 2. 마그넷 그리기 (별도 리스트 사용)
if (_magnets != null)
{
@@ -296,10 +565,17 @@ namespace AGVNavigationCore.Controls
g.DrawLine(_magnetPen, startPoint, endPoint);
}
// 호버된 마그넷 강조
if (magnet == _hoveredNode)
// 호버되거나 선택된 마그넷 강조 (선택: Red, 호버: Orange)
bool isHovered = (magnet == _hoveredNode);
bool isSelected = (magnet == _selectedNode);
if (isHovered || isSelected)
{
using (var highlightPen = new Pen(Color.Orange, 19))
Color highlightColor = isSelected ? Color.Red : Color.Orange;
// 선택된 상태에서 호버되면? -> 선택 색상 우선 (Red) 또는 명확한 구분 필요
// 여기서는 선택이 더 중요하므로 Red 유지
using (var highlightPen = new Pen(highlightColor, 19) { StartCap = LineCap.Round, EndCap = LineCap.Round })
{
if (magnet.ControlPoint != null)
{
@@ -324,16 +600,31 @@ namespace AGVNavigationCore.Controls
g.DrawLine(highlightPen, startPoint, endPoint);
}
}
// Redraw normal to keep it on top? No, highlight is usually outer.
// If I draw highlight AFTER, it covers.
// But DrawMagnet is void. If I draw highlight after, it's fine if I want it to glow.
// Actually _magnetPen is Width 15, very thick.
// If I draw highlight Width 19 *before* normal, it acts as border.
// But this method draws normal first.
// So I should refactor to calculate path first, then draw?
// Or just draw highlight on top with alpha?
// Let's draw highlight on top with non-filled center? No, it's a line.
// I'll draw highlight on top for now, maybe with alpha.
}
// 선택된 마그넷 핸들 그리기
if (magnet == _selectedNode && _canvasMode == CanvasMode.Edit)
{
using (var handleBrush = new SolidBrush(Color.White))
using (var handlePen = new Pen(Color.Black, 1))
{
float size = HANDLE_SIZE / _zoomFactor;
float half = size / 2;
// 시작점, 끝점 핸들
g.FillRectangle(handleBrush, startPoint.X - half, startPoint.Y - half, size, size);
g.DrawRectangle(handlePen, startPoint.X - half, startPoint.Y - half, size, size);
g.FillRectangle(handleBrush, endPoint.X - half, endPoint.Y - half, size, size);
g.DrawRectangle(handlePen, endPoint.X - half, endPoint.Y - half, size, size);
// 제어점 핸들 (곡선일 경우)
if (magnet.ControlPoint != null)
{
var cp = magnet.ControlPoint;
g.FillRectangle(handleBrush, (float)cp.X - half, (float)cp.Y - half, size, size);
g.DrawRectangle(handlePen, (float)cp.X - half, (float)cp.Y - half, size, size);
}
}
}
}
@@ -342,11 +633,10 @@ namespace AGVNavigationCore.Controls
if (_marks == null) return; // _marks 리스트 사용
int sensorSize = 12; // 크기 설정
int lineLength = 20; // 선 길이 설정
int halfLength = lineLength / 2;
foreach (var mark in _marks)
{
int lineLength = (int)mark.Length; // 저장된 길이 사용
int halfLength = lineLength / 2;
Point p = mark.Position;
double radians = mark.Rotation * Math.PI / 180.0;
@@ -368,6 +658,22 @@ namespace AGVNavigationCore.Controls
g.DrawLine(highlightPen, p1, p2);
}
}
// 선택된 마크 핸들 그리기
if (mark == _selectedNode && _canvasMode == CanvasMode.Edit)
{
using (var handleBrush = new SolidBrush(Color.White))
using (var handlePen = new Pen(Color.Black, 1))
{
float size = HANDLE_SIZE / _zoomFactor;
float half = size / 2;
g.FillRectangle(handleBrush, p1.X - half, p1.Y - half, size, size);
g.DrawRectangle(handlePen, p1.X - half, p1.Y - half, size, size);
g.FillRectangle(handleBrush, p2.X - half, p2.Y - half, size, size);
g.DrawRectangle(handlePen, p2.X - half, p2.Y - half, size, size);
}
}
}
}
@@ -525,14 +831,14 @@ namespace AGVNavigationCore.Controls
var angle = Math.Atan2(nextNode.Position.Y - currentNode.Position.Y,
nextNode.Position.X - currentNode.Position.X);
// 상세 경로 정보가 있으면 해당 방향 사용, 없으면 Forward
AgvDirection arrowDir = AgvDirection.Forward;
if (path.DetailedPath != null && i < path.DetailedPath.Count)
{
arrowDir = path.DetailedPath[i].MotorDirection;
}
DrawDirectionArrow(g, midPoint, angle, arrowDir);
}
}
@@ -571,7 +877,7 @@ namespace AGVNavigationCore.Controls
// 현재는 사용자 요청에 따라 Gateway 지정이 안된 경우(일반 경로)에는 교차로 강조를 끄는 것이 맞아 보임.
// 하지만 일반 주행시에도 교차로 정보가 필요할 수 있으니 일단 둡니다.
// 단, Gateway 로직을 타는 경우(HighlightNodeId가 Set됨)에는 위에서 return 되므로 OK.
/*
const int JUNCTION_CONNECTIONS = 3;
@@ -600,8 +906,8 @@ namespace AGVNavigationCore.Controls
Color fillColor = isGateway ? Color.FromArgb(100, 255, 140, 0) : Color.FromArgb(80, 70, 130, 200);
Color penColor = isGateway ? Color.OrangeRed : Color.FromArgb(150, 100, 150, 220);
using (var highlightBrush = new SolidBrush(fillColor))
using (var highlightPen = new Pen(penColor, 3))
using (var highlightBrush = new SolidBrush(fillColor))
using (var highlightPen = new Pen(penColor, 3))
{
g.FillEllipse(
highlightBrush,
@@ -674,7 +980,7 @@ namespace AGVNavigationCore.Controls
{
case NodeType.Normal:
var item = _selectedNode as MapNode;
if ( item.StationType == StationType.Charger1 || item.StationType == StationType.Charger2)
if (item.StationType == Station.Charger)
DrawTriangleGhost(g, ghostBrush);
else
DrawPentagonGhost(g, ghostBrush);
@@ -863,17 +1169,16 @@ namespace AGVNavigationCore.Controls
switch (node.StationType)
{
case StationType.Loader:
case StationType.UnLoader:
case StationType.Clearner:
case StationType.Buffer:
case Station.Loder:
case Station.Cleaner:
case Station.Plating:
case Station.Buffer:
DrawPentagonNodeShape(g, node, brush);
break;
case StationType.Charger1:
case StationType.Charger2:
case Station.Charger:
DrawTriangleNodeShape(g, node, brush);
break;
case StationType.Limit:
case Station.Lmt:
DrawRectangleNodeShape(g, node, brush);
break;
default:
@@ -1285,7 +1590,7 @@ namespace AGVNavigationCore.Controls
// 🔥 노드의 폰트 설정 사용 (0 이하일 경우 기본값 7.0f 사용)
var topFont = new Font("Arial", 9, FontStyle.Bold);
var btmFont = new Font("Arial", 12, FontStyle.Bold);
var btmFont = new Font("Arial", node.NodeTextFontSize, FontStyle.Bold);
// 메인 텍스트 크기 측정
var TopSize = g.MeasureString(TopIDText, topFont);
@@ -1310,22 +1615,21 @@ namespace AGVNavigationCore.Controls
Color fgColor = Color.Black;
Color bgColor = Color.White;
switch (node.StationType)
{
case StationType.Charger1:
case StationType.Charger2:
{
case Station.Charger:
fgColor = Color.White;
bgColor = Color.Tomato;
break;
case StationType.Buffer:
case Station.Buffer:
fgColor = Color.Black;
bgColor = Color.White;
break;
case StationType.Clearner:
case Station.Plating:
fgColor = Color.Black;
bgColor = Color.DeepSkyBlue;
break;
case StationType.Loader:
case StationType.UnLoader:
case Station.Loder:
case Station.Cleaner:
fgColor = Color.Black;
bgColor = Color.Gold;
break;
@@ -1336,6 +1640,8 @@ namespace AGVNavigationCore.Controls
var rectpaddingx = 4;
var rectpaddingy = 2;
var roundRect = new Rectangle((int)(btmPoint.X - rectpaddingx),
@@ -1356,7 +1662,8 @@ namespace AGVNavigationCore.Controls
}
using (var descBrush = new SolidBrush(fgColor))
using (var descBrush = new SolidBrush(node.NodeTextForeColor))
{
g.DrawString(BottomLabelText, btmFont, descBrush, roundRect, new StringFormat
{
@@ -1608,14 +1915,18 @@ namespace AGVNavigationCore.Controls
switch (node.StationType)
{
case StationType.Normal: bgColor = Color.DeepSkyBlue; break;
case StationType.Charger1: bgColor = Color.Tomato; break;
case StationType.Charger2: bgColor = Color.Tomato; break;
case StationType.Loader:
case StationType.UnLoader: bgColor = Color.Gold; break;
case StationType.Clearner: bgColor = Color.DeepSkyBlue; break;
case StationType.Buffer: bgColor = Color.WhiteSmoke; break;
case StationType.Limit: bgColor = Color.Red; break;
case Station.Normal:
if (node.CanTurnLeft || node.CanTurnRight)
bgColor = Color.Violet;
else
bgColor = Color.DeepSkyBlue;
break;
case Station.Charger: bgColor = Color.Tomato; break;
case Station.Loder:
case Station.Cleaner: bgColor = Color.Gold; break;
case Station.Plating: bgColor = Color.DeepSkyBlue; break;
case Station.Buffer: bgColor = Color.WhiteSmoke; break;
case Station.Lmt: bgColor = Color.Red; break;
default: bgColor = Color.White; break;
}
@@ -2294,6 +2605,14 @@ namespace AGVNavigationCore.Controls
g.FillRectangle(bgBrush, scaleRect);
g.DrawRectangle(Pens.Gray, scaleRect.X, scaleRect.Y, scaleRect.Width, scaleRect.Height);
g.DrawString(scaleText, font, Brushes.Black, scaleRect.X + 5, scaleRect.Y + 2);
// 팬 정보 (스케일 정보 위에)
var panText = $"Pan: {_panOffset.X:F1}, {_panOffset.Y:F1}";
var panSize = g.MeasureString(panText, font);
var panRect = new RectangleF(10, Height - zoomSize.Height - scaleSize.Height - panSize.Height - 35, panSize.Width + 10, panSize.Height + 5);
g.FillRectangle(bgBrush, panRect);
g.DrawRectangle(Pens.Gray, panRect.X, panRect.Y, panRect.Width, panRect.Height);
g.DrawString(panText, font, Brushes.Black, panRect.X + 5, panRect.Y + 2);
}

View File

@@ -104,6 +104,10 @@ namespace AGVNavigationCore.Controls
HandleConnectClick(hitNode as MapNode);
break;
case EditMode.ConnectDirection:
HandleConnectDirectionClick(hitNode as MapNode);
break;
case EditMode.Delete:
HandleDeleteClick(hitNode);
break;
@@ -220,12 +224,45 @@ namespace AGVNavigationCore.Controls
{
if (_editMode == EditMode.Move)
{
// 0. 핸들 선택 확인 (이미 선택된 노드가 있을 때)
if (_selectedNode != null)
{
int handleIdx = GetHandleAt(worldPoint);
if (handleIdx != -1)
{
_dragHandleIndex = handleIdx;
// 핸들 드래그 시 초기 오프셋 설정 (점프 현상 방지)
if (_selectedNode is MapMagnet magnet)
{
Point handlePos = Point.Empty;
if (handleIdx == 0) handlePos = magnet.StartPoint;
else if (handleIdx == 1) handlePos = magnet.EndPoint;
else if (handleIdx == 2 && magnet.ControlPoint != null)
handlePos = new Point((int)magnet.ControlPoint.X, (int)magnet.ControlPoint.Y);
_dragOffset = new Point(worldPoint.X - handlePos.X, worldPoint.Y - handlePos.Y);
}
else
{
_dragOffset = Point.Empty; // Mark 등은 오프셋 없이 마우스 포인터 기준 계산
}
_isDragging = true;
_isPanning = false;
Capture = true;
Invalidate();
return;
}
}
// 1. 노드 선택 확인
var hitNode = GetItemAt(worldPoint);
if (hitNode != null)
{
_isDragging = true;
_isPanning = false;
_dragHandleIndex = -1; // 노드 전체 드래그
_selectedNode = hitNode;
_dragStartPosition = hitNode.Position;
_dragOffset = new Point(worldPoint.X - hitNode.Position.X, worldPoint.Y - hitNode.Position.Y);
@@ -322,8 +359,38 @@ namespace AGVNavigationCore.Controls
// 노드 드래그
if (_selectedNode != null)
{
_selectedNode.Position = newPosition;
NodeMoved?.Invoke(this, _selectedNode);
if (_dragHandleIndex != -1)
{
// 핸들 드래그 (포인트별 수정)
if (_selectedNode is MapMagnet magnet)
{
if (_dragHandleIndex == 0) magnet.StartPoint = newPosition;
else if (_dragHandleIndex == 1) magnet.EndPoint = newPosition;
else if (_dragHandleIndex == 2 && magnet.ControlPoint != null)
{
magnet.ControlPoint.X = newPosition.X;
magnet.ControlPoint.Y = newPosition.Y;
}
}
else if (_selectedNode is MapMark mark)
{
// 마크는 중심점 대비 각도와 길이를 계산하여 수정
var dx = newPosition.X - mark.Position.X;
var dy = newPosition.Y - mark.Position.Y;
// 핸들 인덱스에 따라 각도 반전 (p1 vs p2)
if (_dragHandleIndex == 0) { dx = -dx; dy = -dy; }
mark.Rotation = Math.Atan2(dy, dx) * 180.0 / Math.PI;
mark.Length = Math.Sqrt(dx * dx + dy * dy) * 2;
}
}
else
{
// 노드 전체 드래그
_selectedNode.Position = newPosition;
NodeMoved?.Invoke(this, _selectedNode);
}
moved = true;
}
@@ -352,6 +419,7 @@ namespace AGVNavigationCore.Controls
if (_isDragging && _canvasMode == CanvasMode.Edit)
{
_isDragging = false;
_dragHandleIndex = -1;
Capture = false; // 🔥 마우스 캡처 해제
Cursor = GetCursorForMode(_editMode);
}
@@ -463,6 +531,25 @@ namespace AGVNavigationCore.Controls
}
}
if (_marks != null)
{
for (int i = _marks.Count - 1; i >= 0; i--)
{
var node = _marks[i];
if (IsPointInNode(worldPoint, node))
return node;
}
}
if (_magnets != null)
{
for (int i = _magnets.Count - 1; i >= 0; i--)
{
var node = _magnets[i];
if (IsPointInNode(worldPoint, node))
return node;
}
}
return null;
}
@@ -477,6 +564,14 @@ namespace AGVNavigationCore.Controls
{
return IsPointInImage(point, image);
}
if (node is MapMark mark)
{
return IsPointInMark(point, mark);
}
if (node is MapMagnet magnet)
{
return IsPointInMagnet(point, magnet);
}
// 라벨과 이미지는 별도 리스트로 관리되므로 여기서 처리하지 않음
// 하지만 혹시 모를 하위 호환성을 위해 타입 체크는 유지하되,
// 실제 로직은 CircularNode 등으로 분기
@@ -487,13 +582,12 @@ namespace AGVNavigationCore.Controls
{
switch (node.StationType)
{
case StationType.Loader:
case StationType.UnLoader:
case StationType.Clearner:
case StationType.Buffer:
case Station.Loder:
case Station.Cleaner:
case Station.Plating:
case Station.Buffer:
return IsPointInPentagon(point, node);
case StationType.Charger2:
case StationType.Charger1:
case Station.Charger:
return IsPointInTriangle(point, node);
default:
return IsPointInCircle(point, node);
@@ -648,6 +742,55 @@ namespace AGVNavigationCore.Controls
return imageRect.Contains(point);
}
private bool IsPointInMark(Point point, MapMark mark)
{
int lineLength = (int)mark.Length;
int halfLength = lineLength / 2;
double radians = mark.Rotation * Math.PI / 180.0;
int dx = (int)(halfLength * Math.Cos(radians));
int dy = (int)(halfLength * Math.Sin(radians));
Point p1 = new Point(mark.Position.X - dx, mark.Position.Y - dy);
Point p2 = new Point(mark.Position.X + dx, mark.Position.Y + dy);
// 마크 선택을 위해 약간 넉넉한 히트 영역 (7픽셀)
return CalculatePointToLineDistance(point, p1, p2) <= 7 / _zoomFactor;
}
private bool IsPointInMagnet(Point point, MapMagnet magnet)
{
// 마그넷은 두꺼우므로 (Pen Width 15) 절반인 7.5 정도를 히트 영역으로 잡음
float hitThreshold = Math.Max(8f, 12f / _zoomFactor);
if (magnet.ControlPoint != null)
{
// 베지어 곡선 정밀 샘플링 (10개 세그먼트)
Point prevPoint = magnet.StartPoint;
for (int i = 1; i <= 10; i++)
{
float t = i / 10f;
// Quadratic Bezier: (1-t)^2*P0 + 2(1-t)t*P1 + t^2*P2
float u = 1 - t;
float tt = t * t;
float uu = u * u;
float x = uu * magnet.StartPoint.X + 2 * u * t * (float)magnet.ControlPoint.X + tt * magnet.EndPoint.X;
float y = uu * magnet.StartPoint.Y + 2 * u * t * (float)magnet.ControlPoint.Y + tt * magnet.EndPoint.Y;
Point currentPoint = new Point((int)x, (int)y);
if (CalculatePointToLineDistance(point, prevPoint, currentPoint) <= hitThreshold)
return true;
prevPoint = currentPoint;
}
return false;
}
else
{
return CalculatePointToLineDistance(point, magnet.StartPoint, magnet.EndPoint) <= hitThreshold;
}
}
//private MapLabel GetLabelAt(Point worldPoint)
//{
// if (_labels == null) return null;
@@ -764,7 +907,9 @@ namespace AGVNavigationCore.Controls
var newNode = new MapNode
{
Id = newNodeId,
Position = worldPoint
Position = worldPoint,
CanTurnLeft=false,
CanTurnRight= false,
};
_nodes.Add(newNode);
@@ -833,7 +978,7 @@ namespace AGVNavigationCore.Controls
/// <summary>
/// 중복되지 않는 고유한 NodeId 생성
/// </summary>
private string GenerateUniqueNodeId()
public string GenerateUniqueNodeId()
{
string nodeId;
int counter = _nodeCounter;
@@ -875,6 +1020,31 @@ namespace AGVNavigationCore.Controls
Invalidate();
}
private void HandleConnectDirectionClick(MapNode hitNode)
{
if (hitNode == null) return;
if (!_isConnectionMode)
{
// 연결 시작 (방향 설정)
_isConnectionMode = true;
_connectionStartNode = hitNode;
_selectedNode = hitNode;
}
else
{
// 연결 완료
if (_connectionStartNode != null && _connectionStartNode != hitNode)
{
// 기본값 S (Straight)로 방향 설정
SetMagnetDirection(_connectionStartNode, hitNode, MagnetPosition.S);
}
CancelConnection();
}
Invalidate();
}
private void HandleDeleteClick(MapNode hitNode)
{
if (hitNode == null) return;
@@ -902,10 +1072,46 @@ namespace AGVNavigationCore.Controls
toNode.ConnectedNodes.Contains(fromNode.Id))
return;
// 양방향 연결 생성 (AGV가 양쪽 방향으로 이동 가능하도록)
// 양방향 연결 생성 (AGV가 양쪽 방향으로 이동 가능하도록)
fromNode.AddConnection(toNode.Id);
toNode.AddConnection(fromNode.Id);
// 🔥 화면 표시용 ConnectedMapNodes 리스트도 즉시 갱신해야 함
if (!fromNode.ConnectedMapNodes.Contains(toNode))
fromNode.ConnectedMapNodes.Add(toNode);
if (!toNode.ConnectedMapNodes.Contains(fromNode))
toNode.ConnectedMapNodes.Add(fromNode);
ConnectionCreated?.Invoke(this, (fromNode, toNode));
MapChanged?.Invoke(this, EventArgs.Empty);
}
public void SetMagnetDirection(MapNode fromNode, MapNode toNode, MagnetPosition direction)
{
if (fromNode == null || toNode == null) return;
// 이미 연결된 노드인지 확인 (연결되어 있어야 방향 설정 가능)
// 이미 연결된 노드인지 확인 (연결되어 있어야 방향 설정 가능)
if (!fromNode.ConnectedNodes.Contains(toNode.Id))
{
// 연결되어 있지 않으면 자동 연결
CreateConnection(fromNode, toNode);
}
if (fromNode.MagnetDirections == null)
fromNode.MagnetDirections = new Dictionary<string, MagnetPosition>();
if (fromNode.MagnetDirections.ContainsKey(toNode.Id))
{
fromNode.MagnetDirections[toNode.Id] = direction;
}
else
{
fromNode.MagnetDirections.Add(toNode.Id, direction);
}
MapChanged?.Invoke(this, EventArgs.Empty);
}
@@ -1053,8 +1259,8 @@ namespace AGVNavigationCore.Controls
var C = lineEnd.X - lineStart.X;
var D = lineEnd.Y - lineStart.Y;
var dot = A * C + B * D;
var lenSq = C * C + D * D;
var dot = (double)A * C + (double)B * D;
var lenSq = (double)C * C + (double)D * D;
if (lenSq == 0) return CalculateDistance(point, lineStart);
@@ -1102,6 +1308,39 @@ namespace AGVNavigationCore.Controls
}
}
private int GetHandleAt(Point worldPoint)
{
if (_selectedNode == null) return -1;
float hitTolerance = (HANDLE_SIZE + 4) / _zoomFactor;
if (_selectedNode is MapMagnet magnet)
{
if (CalculateDistance(worldPoint, magnet.StartPoint) <= hitTolerance) return 0;
if (CalculateDistance(worldPoint, magnet.EndPoint) <= hitTolerance) return 1;
if (magnet.ControlPoint != null)
{
if (CalculateDistance(worldPoint, new Point((int)magnet.ControlPoint.X, (int)magnet.ControlPoint.Y)) <= hitTolerance) return 2;
}
}
else if (_selectedNode is MapMark mark)
{
int lineLength = (int)mark.Length;
int halfLength = lineLength / 2;
double radians = mark.Rotation * Math.PI / 180.0;
int dx = (int)(halfLength * Math.Cos(radians));
int dy = (int)(halfLength * Math.Sin(radians));
Point p1 = new Point(mark.Position.X - dx, mark.Position.Y - dy);
Point p2 = new Point(mark.Position.X + dx, mark.Position.Y + dy);
if (CalculateDistance(worldPoint, p1) <= hitTolerance) return 0;
if (CalculateDistance(worldPoint, p2) <= hitTolerance) return 1;
}
return -1;
}
#endregion
#region View Control Methods

View File

@@ -20,7 +20,7 @@ namespace AGVNavigationCore.Controls
{
#region Constants
private const int NODE_SIZE = 24;
private const int NODE_SIZE = 18;
private const int NODE_RADIUS = NODE_SIZE / 2;
private const int GRID_SIZE = 20;
private const float CONNECTION_WIDTH = 1.0f;
@@ -56,6 +56,7 @@ namespace AGVNavigationCore.Controls
DeleteConnection, // 연결 삭제 모드
AddLabel, // 라벨 추가 모드
AddImage, // 이미지 추가 모드
ConnectDirection, // 방향 연결 모드
}
#endregion
@@ -109,6 +110,8 @@ namespace AGVNavigationCore.Controls
private MapNode _connectionStartNode;
private Point _connectionEndPoint;
private int _mouseMoveCounter = 0; // 디버그용: MouseMove 실행 횟수
private int _dragHandleIndex = -1; // 드래그 중인 핸들 인덱스
private const int HANDLE_SIZE = 8; // 편집 핸들 크기
// 영역 선택 관련
private bool _isAreaSelecting;
@@ -135,12 +138,28 @@ namespace AGVNavigationCore.Controls
private float _syncProgress = 0.0f;
private string _syncDetail = "";
string _alertmesage = "";
bool showalert = false;
public void SetAlertMessage(string m)
string _systemmesage = "";
string _infomessage = "";
string _tagignoreMessage = "";
bool showalertsystem = false;
bool showinfo = false;
bool showtagigreno = false;
DateTime tagignoretime = DateTime.Now;
public void SetTagIgnore(string m)
{
_alertmesage = m;
showalert = !string.IsNullOrEmpty(m);
_tagignoreMessage = m;
tagignoretime = DateTime.Now;
showtagigreno = !string.IsNullOrEmpty(m);
}
public void SetInfoMessage(string m)
{
_infomessage = m;
showinfo = !string.IsNullOrEmpty(m);
}
public void SetSystemMessage(string m)
{
_systemmesage = m;
showalertsystem = !string.IsNullOrEmpty(m);
}
// 브러쉬 및 펜
@@ -185,6 +204,7 @@ namespace AGVNavigationCore.Controls
public event EventHandler<List<NodeBase>> NodesSelected; // 다중 선택 이벤트
public event EventHandler<NodeBase> NodeDeleted;
public event EventHandler<NodeBase> NodeMoved;
public event EventHandler<(MapNode From, MapNode To)> ConnectionCreated; // 연결 생성 이벤트 추가
public event EventHandler<(MapNode From, MapNode To)> ConnectionDeleted;
public event EventHandler<MapImage> ImageDoubleClicked;
public event EventHandler<MapLabel> LabelDoubleClicked;
@@ -231,6 +251,18 @@ namespace AGVNavigationCore.Controls
{
if (_nodes != null && _nodes.Contains(node))
{
// 🔥 삭제되는 노드와 연결된 다른 노드들의 연결 정보도 삭제
foreach (var otherNode in _nodes.ToList()) // ToList()로 복사본 순회 (안전장치)
{
if (otherNode == node) continue;
// 다른 노드 -> 삭제되는 노드 연결 제거
if (otherNode.ConnectedNodes.Contains(node.Id))
{
otherNode.RemoveConnection(node.Id);
}
}
_nodes.Remove(node);
Invalidate();
}
@@ -291,6 +323,34 @@ namespace AGVNavigationCore.Controls
}
}
/// <summary>
/// 외부에서 Pan(X,Y) 및 Zoom 값을 설정합니다.
/// </summary>
/// <param name="panX">Pan X 좌표</param>
/// <param name="panY">Pan Y 좌표</param>
/// <param name="zoom">Zoom Level (0.1 ~ 5.0)</param>
public void SetView(float panX, float panY, float zoom)
{
// Zoom 값 범위 제한
float newZoom = Math.Max(0.1f, Math.Min(5.0f, zoom));
_panOffset = new PointF(panX, panY);
_zoomFactor = newZoom;
Invalidate();
}
[Browsable(false)]
public PointF PanOffset
{
get => _panOffset;
set
{
_panOffset = value;
Invalidate();
}
}
/// <summary>
/// 그리드 표시 여부
/// </summary>
@@ -345,9 +405,23 @@ namespace AGVNavigationCore.Controls
/// <summary>
/// 선택된 노드 (단일)
/// </summary>
public MapNode SelectedNode
public NodeBase SelectedNode
{
get { return this._selectedNode as MapNode; }
get { return this._selectedNode; }
set
{
_selectedNode = value;
if (value != null)
{
_selectedNodes.Clear();
_selectedNodes.Add(value);
}
else
{
_selectedNodes.Clear();
}
Invalidate();
}
}
/// <summary>
@@ -392,6 +466,19 @@ namespace AGVNavigationCore.Controls
this.FitToNodes();
}
/// <summary>
/// 맵 데이터를 셋팅합니다
/// </summary>
public void SetMapData(List<MapNode> nodes, List<MapLabel> labels = null, List<MapImage> images = null, List<MapMark> marks = null, List<MapMagnet> magnets = null)
{
this.Nodes = nodes;
this.Labels = labels ?? new List<MapLabel>();
this.Images = images ?? new List<MapImage>();
this.Marks = marks ?? new List<MapMark>();
this.Magnets = magnets ?? new List<MapMagnet>();
this.FitToNodes();
}
/// <summary>
/// 노드 목록
/// </summary>
@@ -656,8 +743,8 @@ namespace AGVNavigationCore.Controls
_destinationNodePen = new Pen(Color.Orange, 4);
_pathPen = new Pen(Color.Purple, 3);
_agvPen = new Pen(Color.Red, 3);
_highlightedConnectionPen = new Pen(Color.Red, 4) { DashStyle = DashStyle.Solid };
_magnetPen = new Pen(Color.FromArgb(100, Color.LightSkyBlue), 15) { DashStyle = DashStyle.Solid };
_highlightedConnectionPen = new Pen(Color.Red, 6) { DashStyle = DashStyle.Solid };
_magnetPen = new Pen(Color.FromArgb(100, Color.LightSkyBlue), 15) { DashStyle = DashStyle.Solid, StartCap = LineCap.Round, EndCap = LineCap.Round };
_markPen = new Pen(Color.White, 3); // 마크는 흰색 선으로 표시
}
@@ -810,11 +897,11 @@ namespace AGVNavigationCore.Controls
/// <summary>
/// 동기화 모드 종료
/// </summary>
public void ExitSyncMode()
public void ExitSyncMode(CanvasMode newmode)
{
if (_canvasMode == CanvasMode.Sync)
{
_canvasMode = CanvasMode.Edit; // 기본 모드로 복귀 (또는 이전 모드)
_canvasMode = newmode; // 기본 모드로 복귀 (또는 이전 모드)
UpdateModeUI();
Invalidate();
}
@@ -858,6 +945,7 @@ namespace AGVNavigationCore.Controls
// 이미지 정리
_companyLogo?.Dispose();
}
base.Dispose(disposing);

View File

@@ -21,6 +21,9 @@
/// <summary>명령 이유- (디버깅/로깅용)</summary>
public eAGVCommandReason Reason { get; set; }
/// <summary>방향 전환 명령 여부 (180도 Left Turn 등)</summary>
public bool IsTurn { get; set; }
/// <summary>
/// 생성자
/// </summary>

View File

@@ -58,29 +58,27 @@ namespace AGVNavigationCore.Models
/// <summary>
/// 장비 타입 열거형
/// </summary>
public enum StationType
public enum Station
{
/// <summary>
/// 일반노드
/// </summary>
Normal,
/// <summary>로더</summary>
Loader,
Loder,
/// <summary>클리너</summary>
Clearner,
Plating,
/// <summary>오프로더</summary>
UnLoader,
Cleaner,
/// <summary>버퍼</summary>
Buffer,
/// <summary>충전기1</summary>
Charger1,
/// <summary>충전기2</summary>
Charger2,
Charger,
/// <summary>
/// 끝점(더이상 이동불가)
/// </summary>
Limit,
Lmt,
}
@@ -179,4 +177,7 @@ namespace AGVNavigationCore.Models
Complete,
}
}

View File

@@ -56,17 +56,37 @@ namespace AGVNavigationCore.Models
}
/// <summary>
/// 시작점 Point 반환
/// 시작점 Point 반환 및 설정
/// </summary>
[Browsable(false)]
[JsonIgnore]
public Point StartPoint => new Point((int)P1.X, (int)P1.Y);
public Point StartPoint
{
get => new Point((int)P1.X, (int)P1.Y);
set { P1.X = value.X; P1.Y = value.Y; }
}
/// <summary>
/// 끝점 Point 반환
/// 끝점 Point 반환 및 설정
/// </summary>
[Browsable(false)]
[JsonIgnore]
public Point EndPoint => new Point((int)P2.X, (int)P2.Y);
public Point EndPoint
{
get => new Point((int)P2.X, (int)P2.Y);
set { P2.X = value.X; P2.Y = value.Y; }
}
public override string ToString()
{
if (ControlPoint == null)
{
return $"[LINE] ({P1.X:F0},{P1.Y:F0}) -> ({P2.X:F0},{P2.Y:F0})";
}
else
{
return $"[CURVE] ({P1.X:F0},{P1.Y:F0}) -> ({P2.X:F0},{P2.Y:F0})";
}
}
}
}

View File

@@ -33,5 +33,9 @@ namespace AGVNavigationCore.Models
[Category("위치 정보")]
[Description("마크의 회전 각도")]
public double Rotation { get; set; }
[Category("위치 정보")]
[Description("마크의 길이")]
public double Length { get; set; } = 20.0;
}
}

View File

@@ -15,23 +15,20 @@ namespace AGVNavigationCore.Models
{
[Category("라벨 설정")]
[Description("표시할 텍스트입니다.")]
public string Text { get; set; } = "";
public StationType StationType { get; set; }
public Station StationType { get; set; }
[Browsable(false)]
public bool CanDocking
{
get
{
if (StationType == StationType.Buffer) return true;
if (StationType == StationType.Loader) return true;
if (StationType == StationType.UnLoader) return true;
if (StationType == StationType.Clearner) return true;
if (StationType == StationType.Charger1) return true;
if (StationType == StationType.Charger2) return true;
if (StationType == Station.Buffer) return true;
if (StationType == Station.Loder) return true;
if (StationType == Station.Cleaner) return true;
if (StationType == Station.Plating) return true;
if (StationType == Station.Charger) return true;
return false;
}
}
@@ -40,6 +37,11 @@ namespace AGVNavigationCore.Models
[Description("도킹/충전 노드의 진입 방향입니다.")]
public DockingDirection DockDirection { get; set; } = DockingDirection.DontCare;
[Category("노드 설정")]
[Description("각 연결된 노드로 향할 때의 마그넷 방향 정보입니다.")]
public Dictionary<string, MagnetPosition> MagnetDirections { get; set; } = new Dictionary<string, MagnetPosition>();
[Category("연결 정보")]
[Description("연결된 노드 ID 목록입니다.")]
[ReadOnly(true)]
@@ -51,11 +53,11 @@ namespace AGVNavigationCore.Models
[Category("주행 설정")]
[Description("제자리 회전(좌) 가능 여부입니다.")]
public bool CanTurnLeft { get; set; } = true;
public bool CanTurnLeft { get; set; } = false;
[Category("주행 설정")]
[Description("제자리 회전(우) 가능 여부입니다.")]
public bool CanTurnRight { get; set; } = true;
public bool CanTurnRight { get; set; } = false;
[Category("주행 설정")]
[Description("교차로 주행 가능 여부입니다.")]
@@ -68,11 +70,11 @@ namespace AGVNavigationCore.Models
}
set { _disablecross = value; }
}
private bool _disablecross = false;
private bool _disablecross = true;
[Category("주행 설정")]
[Description("노드 통과 시 제한 속도입니다.")]
public SpeedLevel SpeedLimit { get; set; } = SpeedLevel.M;
public SpeedLevel SpeedLimit { get; set; } = SpeedLevel.L;
[Category("노드 설정")]
[Description("장비 ID 또는 별칭입니다.")]
@@ -100,12 +102,16 @@ namespace AGVNavigationCore.Models
set => _textFontSize = value > 0 ? value : 7.0f;
}
[Category("노드 텍스트")]
[Description("표시할 텍스트입니다.")]
public string Text { get; set; } = "";
public MapNode() : base()
{
Type = NodeType.Normal;
}
public MapNode(string nodeId, Point position, StationType type) : base(nodeId, position)
public MapNode(string nodeId, Point position, Station type) : base(nodeId, position)
{
Type = NodeType.Normal;
}
@@ -116,9 +122,9 @@ namespace AGVNavigationCore.Models
{
get
{
if (StationType == StationType.Charger1 || StationType == StationType.Charger2 || StationType == StationType.Buffer ||
StationType == StationType.Clearner || StationType == StationType.Loader ||
StationType == StationType.UnLoader) return true;
if (StationType == Station.Charger || StationType == Station.Buffer ||
StationType == Station.Plating || StationType == Station.Loder ||
StationType == Station.Cleaner) return true;
return false;
}
}
@@ -136,6 +142,15 @@ namespace AGVNavigationCore.Models
{
if (ConnectedNodes.Remove(nodeId))
{
if (MagnetDirections != null && MagnetDirections.ContainsKey(nodeId))
{
MagnetDirections.Remove(nodeId);
}
// 🔥 ConnectedMapNodes에서도 제거 (화면 갱신용)
var target = ConnectedMapNodes.Find(n => n.Id == nodeId);
if (target != null) ConnectedMapNodes.Remove(target);
ModifiedDate = DateTime.Now;
}
}

View File

@@ -1,6 +1,4 @@
using AGVNavigationCore.Models;
namespace AGVNavigationCore.PathFinding.Planning
namespace AGVNavigationCore.Models
{
/// <summary>
/// AGV 마그넷 센서 방향 제어
@@ -60,7 +58,7 @@ namespace AGVNavigationCore.PathFinding.Planning
/// <summary>
/// 다음 노드 ID (경로예측용)
/// </summary>
public string NextNodeId { get; set; }
public MapNode NextNode { get; set; }
/// <summary>
/// 회전 가능 노드 여부
@@ -82,19 +80,22 @@ namespace AGVNavigationCore.PathFinding.Planning
/// </summary>
public bool IsPass { get; set; }
public bool IsTurn { get; set; }
/// <summary>
/// 특수 동작 설명
/// </summary>
public string SpecialActionDescription { get; set; }
public NodeMotorInfo(int seqno,string nodeId,ushort rfid, AgvDirection motorDirection, string nextNodeId = null, MagnetDirection magnetDirection = MagnetDirection.Straight)
public NodeMotorInfo(int seqno,string nodeId,ushort rfid,
AgvDirection motorDirection, MapNode nextNodeId = null, MagnetDirection magnetDirection = MagnetDirection.Straight,bool turn=false)
{
IsTurn = turn;
seq = seqno;
NodeId = nodeId;
RfidId = rfid;
MotorDirection = motorDirection;
MagnetDirection = magnetDirection;
NextNodeId = nextNodeId;
NextNode = nextNodeId;
CanRotate = false;
IsDirectionChangePoint = false;
RequiresSpecialAction = false;
@@ -108,7 +109,7 @@ namespace AGVNavigationCore.PathFinding.Planning
/// </summary>
public override string ToString()
{
var result = $"R{RfidId}[N{NodeId}]:{MotorDirection}";
var result = $"R{RfidId}[*{NodeId}]:{MotorDirection}";
// 마그넷 방향이 직진이 아닌 경우 표시
if (MagnetDirection != MagnetDirection.Straight)

View File

@@ -56,7 +56,7 @@ namespace AGVNavigationCore.Models
private AgvDirection _prevDirection;
private AGVState _currentState;
private float _currentSpeed;
private MapNode _targetnode = null;
// 경로 관련
private AGVPathResult _currentPath;
private List<string> _remainingNodes;
@@ -92,7 +92,6 @@ namespace AGVNavigationCore.Models
#region Properties
public bool Turn180 { get; set; } = false;
/// <summary>
/// 대상 이동시 모터 방향
@@ -312,7 +311,6 @@ namespace AGVNavigationCore.Models
/// <returns>다음에 수행할 모터/마그넷/속도 명령</returns>
public AGVCommand Predict()
{
// 1. 위치 미확정 상태 (RFID 2개 미만 감지)
if (!_isPositionConfirmed)
{
@@ -347,12 +345,11 @@ namespace AGVNavigationCore.Models
var lastNode = _currentPath.DetailedPath.Last();
if (_currentPath.DetailedPath.Where(t => t.seq < lastNode.seq && t.IsPass == false).Any() == false)
{
// 마지막 노드에 도착했는지 확인 (현재 노드가 마지막 노드와 같은지)
if (_currentNode != null && _currentNode.Id == lastNode.NodeId)
// 마지막 노드에 도착했는지 확인 (현재 노드가 마지막 노드와 같은지) -
// 모터방향오 같아야한다. 간혹 방향전환 후 MARK STOP하는경우가있다. 260127
if (_currentNode != null && _currentNode.Id == lastNode.NodeId && lastNode.MotorDirection == CurrentDirection)
{
if (lastNode.IsPass) //이미완료되었다.
{
return new AGVCommand(
@@ -365,12 +362,23 @@ namespace AGVNavigationCore.Models
}
else
{
//움직이지 않는다면 움직이게하고, 움직인다면 마크스탑하낟.i
//도킹노드라면 markstop 을 나머지는 바로 스탑한다.
eAGVCommandReason reason = eAGVCommandReason.MarkStop;
if (TargetNode.StationType == Station.Normal || TargetNode.StationType == Station.Lmt)
{
//일반노드는 마크스탑포인트가 없으니 바로 종료되도록 한다
reason = eAGVCommandReason.Complete;
}
//마지막노드는 일혔지만 완료되지 않았다. 마크스탑필요
return new AGVCommand(
MotorCommand.Stop,
MagnetPosition.S,
SpeedLevel.L,
eAGVCommandReason.MarkStop,
reason,
$"목적지 도착 전(MarkStop) - 최종:{CurrentNodeID2}"
);
}
@@ -379,8 +387,8 @@ namespace AGVNavigationCore.Models
}
// 4. 경로이탈
var TargetNode = _currentPath.DetailedPath.Where(t => t.IsPass == false && t.NodeId.Equals(_currentNode.Id)).FirstOrDefault();
if (TargetNode == null)
var checkPathOutNode = _currentPath.DetailedPath.Where(t => t.IsPass == false && t.NodeId.Equals(_currentNode.Id)).FirstOrDefault();
if (checkPathOutNode == null)
{
return new AGVCommand(
MotorCommand.Stop,
@@ -712,30 +720,40 @@ namespace AGVNavigationCore.Models
// MotorDirection → MotorCommand 변환
MotorCommand motorCmd;
switch (nodeInfo.MotorDirection)
eAGVCommandReason reason = eAGVCommandReason.Normal;
if (nodeInfo.IsTurn)
{
case AgvDirection.Forward:
motorCmd = MotorCommand.Forward;
break;
case AgvDirection.Backward:
motorCmd = MotorCommand.Backward;
break;
default:
motorCmd = MotorCommand.Stop;
break;
motorCmd = MotorCommand.Stop;
reason = eAGVCommandReason.MarkStop;
}
else
{
switch (nodeInfo.MotorDirection)
{
case AgvDirection.Forward:
motorCmd = MotorCommand.Forward;
break;
case AgvDirection.Backward:
motorCmd = MotorCommand.Backward;
break;
default:
motorCmd = MotorCommand.Stop;
break;
}
}
// MagnetDirection → MagnetPosition 변换
MagnetPosition magnetPos;
switch (nodeInfo.MagnetDirection)
{
case PathFinding.Planning.MagnetDirection.Left:
case MagnetDirection.Left:
magnetPos = MagnetPosition.L;
break;
case PathFinding.Planning.MagnetDirection.Right:
case MagnetDirection.Right:
magnetPos = MagnetPosition.R;
break;
case PathFinding.Planning.MagnetDirection.Straight:
case MagnetDirection.Straight:
default:
magnetPos = MagnetPosition.S;
break;
@@ -753,9 +771,12 @@ namespace AGVNavigationCore.Models
motorCmd,
magnetPos,
speed,
eAGVCommandReason.Normal,
reason,
$"{actionDescription} → {targetNode.Id} (Motor:{motorCmd}, Magnet:{magnetPos})"
);
)
{
IsTurn = nodeInfo.IsTurn
};
}
private void StartMovement()
@@ -826,9 +847,7 @@ namespace AGVNavigationCore.Models
}
public MapNode StartNode { get; set; } = null;
private MapNode _targetnode = null;
/// <summary>
/// 목적지를 설정합니다. 목적지가 변경되면 경로계산정보가 삭제 됩니다.
/// </summary>
@@ -848,6 +867,10 @@ namespace AGVNavigationCore.Models
}
}
private void ProcessNextNode()
{
if (_remainingNodes == null || _currentNodeIndex >= _remainingNodes.Count - 1)

View File

@@ -64,7 +64,7 @@ namespace AGVNavigationCore.PathFinding.Core
/// <summary>
/// 오류 메시지 (실패시)
/// </summary>
public string ErrorMessage { get; set; }
public string Message { get; set; }
/// <summary>
/// 도킹 검증 결과
@@ -102,6 +102,8 @@ namespace AGVNavigationCore.PathFinding.Core
/// </summary>
public AgvDirection PrevDirection { get; set; }
public MapNode Gateway { get; set; }
/// <summary>
/// 기본 생성자
/// </summary>
@@ -116,7 +118,7 @@ namespace AGVNavigationCore.PathFinding.Core
ExploredNodes = 0;
EstimatedTimeSeconds = 0;
RotationCount = 0;
ErrorMessage = string.Empty;
Message = string.Empty;
PlanDescription = string.Empty;
RequiredDirectionChange = false;
DirectionChangeNode = string.Empty;
@@ -148,39 +150,22 @@ namespace AGVNavigationCore.PathFinding.Core
return result;
}
/// <summary>
/// 실패 결과 생성
/// </summary>
/// <param name="errorMessage">오류 메시지</param>
/// <param name="calculationTimeMs">계산 시간</param>
/// <returns>실패 결과</returns>
public static AGVPathResult CreateFailure(string errorMessage, long calculationTimeMs)
{
return new AGVPathResult
{
Success = false,
ErrorMessage = errorMessage,
CalculationTimeMs = calculationTimeMs
};
}
/// <summary>
/// 실패 결과 생성 (확장)
/// </summary>
/// <param name="errorMessage">오류 메시지</param>
/// <param name="calculationTimeMs">계산 시간</param>
/// <param name="exploredNodes">탐색된 노드 수</param>
/// <returns>실패 결과</returns>
public static AGVPathResult CreateFailure(string errorMessage, long calculationTimeMs, int exploredNodes)
public static AGVPathResult CreateFailure(string errorMessage, long calculationTimeMs = 0, int exploredNodes = 0)
{
return new AGVPathResult
{
Success = false,
ErrorMessage = errorMessage,
Message = errorMessage,
CalculationTimeMs = calculationTimeMs,
ExploredNodes = exploredNodes
ExploredNodes = exploredNodes,
};
}
@@ -276,37 +261,25 @@ namespace AGVNavigationCore.PathFinding.Core
}
}
/// <summary>
/// 상세 경로 정보 반환
/// </summary>
/// <returns>상세 정보 문자열</returns>
public string GetDetailedInfo()
{
if (!Success)
{
return $"경로 계산 실패: {ErrorMessage} (계산시간: {CalculationTimeMs}ms)";
}
return $"경로: {Path.Count}개 노드, 거리: {TotalDistance:F1}px, " +
$"회전: {RotationCount}회, 예상시간: {EstimatedTimeSeconds:F1}초, " +
$"계산시간: {CalculationTimeMs}ms";
}
/// <summary>
/// 경로의 노드 정보를 포함
/// </summary>
/// <returns></returns>
public string GetDetailedPathInfo()
public string GetDetailedPathInfo(bool shortmessage = false)
{
if (!Success)
{
return $"경로 계산 실패: {ErrorMessage} (계산시간: {CalculationTimeMs}ms)";
return $"경로 계산 실패: {Message} (계산시간: {CalculationTimeMs}ms)";
}
var data = DetailedPath.Select(t => {
return $"{t.RfidId}[{t.NodeId}] {t.MotorDirection.ToString().Substring(0,1)}-{t.MagnetDirection.ToString().Substring(0,1)}";
var data = DetailedPath.Select(t =>
{
if (shortmessage)
return $"{t.RfidId:00}{t.MotorDirection.ToString().Substring(0, 1)}{t.MagnetDirection.ToString().Substring(0, 1)}";
else
return $"{t.RfidId}[{t.NodeId}] {t.MotorDirection.ToString().Substring(0, 1)}-{t.MagnetDirection.ToString().Substring(0, 1)}";
});
return string.Join(" → ",data);
return string.Join(" → ", data);
}
@@ -322,7 +295,7 @@ namespace AGVNavigationCore.PathFinding.Core
}
return Path?.Select(n => n.Id).ToList() ?? new List<string>();
}
/// <summary>
/// 문자열 표현
/// </summary>
@@ -334,7 +307,7 @@ namespace AGVNavigationCore.PathFinding.Core
}
else
{
return $"Failed: {ErrorMessage}";
return $"Failed: {Message}";
}
}
}

View File

@@ -181,277 +181,6 @@ namespace AGVNavigationCore.PathFinding.Core
}
}
///// <summary>
///// 경유지를 거쳐 경로 찾기 (오버로드)
///// 여러 경유지를 순차적으로 거쳐서 최종 목적지까지의 경로를 계산합니다.
///// 기존 FindPath를 여러 번 호출하여 각 구간의 경로를 합칩니다.
///// </summary>
///// <param name="startNodeId">시작 노드 ID</param>
///// <param name="endNodeId">최종 목적지 노드 ID</param>
///// <param name="waypointNodeIds">경유지 노드 ID 배열 (선택사항)</param>
///// <returns>경로 계산 결과 (모든 경유지를 거친 전체 경로)</returns>
//public AGVPathResult FindPath(string startNodeId, string endNodeId, params string[] waypointNodeIds)
//{
// var stopwatch = System.Diagnostics.Stopwatch.StartNew();
// try
// {
// // 경유지가 없으면 기본 FindPath 호출
// if (waypointNodeIds == null || waypointNodeIds.Length == 0)
// {
// return FindPathAStar(startNodeId, endNodeId);
// }
// // 경유지 유효성 검증
// var validWaypoints = new List<string>();
// foreach (var waypointId in waypointNodeIds)
// {
// if (string.IsNullOrEmpty(waypointId))
// continue;
// if (!_nodeMap.ContainsKey(waypointId))
// {
// return AGVPathResult.CreateFailure($"경유지 노드를 찾을 수 없습니다: {waypointId}", stopwatch.ElapsedMilliseconds, 0);
// }
// validWaypoints.Add(waypointId);
// }
// // 경유지가 없으면 기본 경로 계산
// if (validWaypoints.Count == 0)
// {
// return FindPathAStar(startNodeId, endNodeId);
// }
// // 첫 번째 경유지가 시작노드와 같은지 검사
// if (validWaypoints[0] == startNodeId)
// {
// return AGVPathResult.CreateFailure(
// $"첫 번째 경유지({validWaypoints[0]})가 시작 노드({startNodeId})와 동일합니다. 경유지는 시작노드와 달라야 합니다.",
// stopwatch.ElapsedMilliseconds, 0);
// }
// // 마지막 경유지가 목적지노드와 같은지 검사
// if (validWaypoints[validWaypoints.Count - 1] == endNodeId)
// {
// return AGVPathResult.CreateFailure(
// $"마지막 경유지({validWaypoints[validWaypoints.Count - 1]})가 목적지 노드({endNodeId})와 동일합니다. 경유지는 목적지노드와 달라야 합니다.",
// stopwatch.ElapsedMilliseconds, 0);
// }
// // 연속된 중복만 제거 (순서 유지)
// // 예: [1, 2, 2, 3, 2] -> [1, 2, 3, 2] (연속 중복만 제거)
// var deduplicatedWaypoints = new List<string>();
// string lastWaypoint = null;
// foreach (var waypoint in validWaypoints)
// {
// if (waypoint != lastWaypoint)
// {
// deduplicatedWaypoints.Add(waypoint);
// lastWaypoint = waypoint;
// }
// }
// validWaypoints = deduplicatedWaypoints;
// // 최종 경로 리스트와 누적 값
// var combinedPath = new List<MapNode>();
// float totalDistance = 0;
// long totalCalculationTime = 0;
// // 현재 시작점
// string currentStart = startNodeId;
// // 1단계: 각 경유지까지의 경로 계산
// for (int i = 0; i < validWaypoints.Count; i++)
// {
// string waypoint = validWaypoints[i];
// // 현재 위치에서 경유지까지의 경로 계산
// var segmentResult = FindPathAStar(currentStart, waypoint);
// if (!segmentResult.Success)
// {
// return AGVPathResult.CreateFailure(
// $"경유지 {i + 1}({waypoint})까지의 경로 계산 실패: {segmentResult.ErrorMessage}",
// stopwatch.ElapsedMilliseconds, 0);
// }
// // 경로 합치기 (첫 번째 구간이 아니면 시작점 제거하여 중복 방지)
// if (combinedPath.Count > 0 && segmentResult.Path.Count > 0)
// {
// // 시작 노드 제거 (이전 경로의 마지막 노드와 동일)
// combinedPath.AddRange(segmentResult.Path.Skip(1));
// }
// else
// {
// combinedPath.AddRange(segmentResult.Path);
// }
// totalDistance += segmentResult.TotalDistance;
// totalCalculationTime += segmentResult.CalculationTimeMs;
// // 다음 경유지의 시작점은 현재 경유지
// currentStart = waypoint;
// }
// // 2단계: 마지막 경유지에서 최종 목적지까지의 경로 계산
// var finalSegmentResult = FindPathAStar(currentStart, endNodeId);
// if (!finalSegmentResult.Success)
// {
// return AGVPathResult.CreateFailure(
// $"최종 목적지까지의 경로 계산 실패: {finalSegmentResult.ErrorMessage}",
// stopwatch.ElapsedMilliseconds, 0);
// }
// // 최종 경로 합치기 (시작점 제거)
// if (combinedPath.Count > 0 && finalSegmentResult.Path.Count > 0)
// {
// combinedPath.AddRange(finalSegmentResult.Path.Skip(1));
// }
// else
// {
// combinedPath.AddRange(finalSegmentResult.Path);
// }
// totalDistance += finalSegmentResult.TotalDistance;
// totalCalculationTime += finalSegmentResult.CalculationTimeMs;
// stopwatch.Stop();
// // 결과 생성
// return AGVPathResult.CreateSuccess(
// combinedPath,
// new List<AgvDirection>(),
// totalDistance,
// totalCalculationTime
// );
// }
// catch (Exception ex)
// {
// return AGVPathResult.CreateFailure($"경로 계산 중 오류: {ex.Message}", stopwatch.ElapsedMilliseconds, 0);
// }
//}
/// <summary>
/// 두 경로 결과를 합치기
/// 이전 경로의 마지막 노드와 현재 경로의 시작 노드가 같으면 시작 노드를 제거하고 합침
/// </summary>
/// <param name="previousResult">이전 경로 결과</param>
/// <param name="currentResult">현재 경로 결과</param>
/// <returns>합쳐진 경로 결과</returns>
public AGVPathResult CombineResults( AGVPathResult previousResult, AGVPathResult currentResult)
{
// 입력 검증
if (previousResult == null)
return currentResult;
if (currentResult == null)
return previousResult;
if (!previousResult.Success)
return AGVPathResult.CreateFailure(
$"이전 경로 결과 실패: {previousResult.ErrorMessage}",
previousResult.CalculationTimeMs);
if (!currentResult.Success)
return AGVPathResult.CreateFailure(
$"현재 경로 결과 실패: {currentResult.ErrorMessage}",
currentResult.CalculationTimeMs);
// 경로가 비어있는 경우 처리
if (previousResult.Path == null || previousResult.Path.Count == 0)
return currentResult;
if (currentResult.Path == null || currentResult.Path.Count == 0)
return previousResult;
// 합친 경로 생성
var combinedPath = new List<MapNode>(previousResult.Path);
var combinedCommands = new List<AgvDirection>(previousResult.Commands);
var combinedDetailedPath = new List<NodeMotorInfo>(previousResult.DetailedPath ?? new List<NodeMotorInfo>());
// 이전 경로의 마지막 노드와 현재 경로의 시작 노드 비교
string lastNodeOfPrevious = previousResult.Path[previousResult.Path.Count - 1].Id;
string firstNodeOfCurrent = currentResult.Path[0].Id;
if (lastNodeOfPrevious == firstNodeOfCurrent)
{
// 첫 번째 노드 제거 (중복 제거)
combinedPath.RemoveAt(combinedPath.Count - 1);
combinedPath.AddRange(currentResult.Path);
// DetailedPath도 첫 번째 노드 제거
if (currentResult.DetailedPath != null && currentResult.DetailedPath.Count > 0)
{
combinedDetailedPath.RemoveAt(combinedDetailedPath.Count - 1);
combinedDetailedPath.AddRange(currentResult.DetailedPath);
}
}
else
{
// 그대로 붙임
combinedPath.AddRange(currentResult.Path);
// DetailedPath도 그대로 붙임
if (currentResult.DetailedPath != null && currentResult.DetailedPath.Count > 0)
{
combinedDetailedPath.AddRange(currentResult.DetailedPath);
}
}
// 명령어 합치기
combinedCommands.AddRange(currentResult.Commands);
// 총 거리 합산
float combinedDistance = previousResult.TotalDistance + currentResult.TotalDistance;
// 계산 시간 합산
long combinedCalculationTime = previousResult.CalculationTimeMs + currentResult.CalculationTimeMs;
// 합쳐진 결과 생성
var result = AGVPathResult.CreateSuccess(
combinedPath,
combinedCommands,
combinedDistance,
combinedCalculationTime
);
// DetailedPath 설정
result.DetailedPath = combinedDetailedPath;
result.PrevNode = previousResult.PrevNode;
result.PrevDirection = previousResult.PrevDirection;
return result;
}
///// <summary>
///// 여러 목적지 중 가장 가까운 노드로의 경로 찾기
///// </summary>
///// <param name="startNodeId">시작 노드 ID</param>
///// <param name="targetNodeIds">목적지 후보 노드 ID 목록</param>
///// <returns>경로 계산 결과</returns>
//public AGVPathResult FindNearestPath(string startNodeId, List<string> targetNodeIds)
//{
// if (targetNodeIds == null || targetNodeIds.Count == 0)
// {
// return AGVPathResult.CreateFailure("목적지 노드가 지정되지 않았습니다", 0, 0);
// }
// AGVPathResult bestResult = null;
// foreach (var targetId in targetNodeIds)
// {
// var result = FindPathAStar(startNodeId, targetId);
// if (result.Success && (bestResult == null || result.TotalDistance < bestResult.TotalDistance))
// {
// bestResult = result;
// }
// }
// return bestResult ?? AGVPathResult.CreateFailure("모든 목적지로의 경로를 찾을 수 없습니다", 0, 0);
//}
/// <summary>
/// 휴리스틱 거리 계산 (유클리드 거리)
/// </summary>

View File

@@ -0,0 +1,106 @@
using AGVNavigationCore.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVNavigationCore.PathFinding.Core
{
public static class Utility
{
/// <summary>
/// 두 경로 결과를 합치기
/// 이전 경로의 마지막 노드와 현재 경로의 시작 노드가 같으면 시작 노드를 제거하고 합침
/// </summary>
/// <param name="previousResult">이전 경로 결과</param>
/// <param name="currentResult">현재 경로 결과</param>
/// <returns>합쳐진 경로 결과</returns>
public static AGVPathResult CombineResults(AGVPathResult previousResult, AGVPathResult currentResult)
{
// 입력 검증
if (previousResult == null)
return currentResult;
if (currentResult == null)
return previousResult;
if (!previousResult.Success)
return AGVPathResult.CreateFailure(
$"이전 경로 결과 실패: {previousResult.Message}",
previousResult.CalculationTimeMs);
if (!currentResult.Success)
return AGVPathResult.CreateFailure(
$"현재 경로 결과 실패: {currentResult.Message}",
currentResult.CalculationTimeMs);
// 경로가 비어있는 경우 처리
if (previousResult.Path == null || previousResult.Path.Count == 0)
return currentResult;
if (currentResult.Path == null || currentResult.Path.Count == 0)
return previousResult;
// 합친 경로 생성
var combinedPath = new List<MapNode>(previousResult.Path);
var combinedCommands = new List<AgvDirection>(previousResult.Commands);
var combinedDetailedPath = new List<NodeMotorInfo>(previousResult.DetailedPath ?? new List<NodeMotorInfo>());
// 이전 경로의 마지막 노드와 현재 경로의 시작 노드 비교
string lastNodeOfPrevious = previousResult.Path[previousResult.Path.Count - 1].Id;
string firstNodeOfCurrent = currentResult.Path[0].Id;
if (lastNodeOfPrevious == firstNodeOfCurrent)
{
// 첫 번째 노드 제거 (중복 제거)
combinedPath.RemoveAt(combinedPath.Count - 1);
combinedPath.AddRange(currentResult.Path);
// DetailedPath도 첫 번째 노드 제거
if (currentResult.DetailedPath != null && currentResult.DetailedPath.Count > 0)
{
combinedDetailedPath.RemoveAt(combinedDetailedPath.Count - 1);
combinedDetailedPath.AddRange(currentResult.DetailedPath);
}
}
else
{
// 그대로 붙임
combinedPath.AddRange(currentResult.Path);
// DetailedPath도 그대로 붙임
if (currentResult.DetailedPath != null && currentResult.DetailedPath.Count > 0)
{
combinedDetailedPath.AddRange(currentResult.DetailedPath);
}
}
// 명령어 합치기
combinedCommands.AddRange(currentResult.Commands);
// 총 거리 합산
float combinedDistance = previousResult.TotalDistance + currentResult.TotalDistance;
// 계산 시간 합산
long combinedCalculationTime = previousResult.CalculationTimeMs + currentResult.CalculationTimeMs;
// 합쳐진 결과 생성
var result = AGVPathResult.CreateSuccess(
combinedPath,
combinedCommands,
combinedDistance,
combinedCalculationTime
);
// DetailedPath 설정
result.DetailedPath = combinedDetailedPath;
result.PrevNode = previousResult.PrevNode;
result.PrevDirection = previousResult.PrevDirection;
return result;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var paths = new List<string[]> { new[] { \"20F\", \"21F\", \"70B\" } };
var valid = paths.Select(p => p.Select(t => new { Tag = t, IdStr = new string(t.Where(char.IsDigit).ToArray()) }).ToList()).ToList();
Console.WriteLine(\"Compiled\");
}
}

View File

@@ -191,7 +191,7 @@ namespace AGVNavigationCore.Utils
}
// 검증 수행
if (LastNodeInfo.MotorDirection == requiredDirection && pathResult.DetailedPath[pathResult.DetailedPath.Count - 2].MotorDirection == requiredDirection)
if (LastNodeInfo.MotorDirection == requiredDirection && pathResult.DetailedPath[pathResult.DetailedPath.Count - 1].MotorDirection == requiredDirection)
{
System.Diagnostics.Debug.WriteLine($"[DockingValidator] ✅ 도킹 검증 성공");
return DockingValidationResult.CreateValid(

View File

@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\..\Amkor\AGV4\Test\Simulator\</OutputPath>
<OutputPath>bin\debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -45,6 +45,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="fMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fMain.Designer.cs">
<DependentUpon>fMain.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ComboBoxItem.cs" />
<Compile Include="Forms\DirectionItem.cs" />
<Compile Include="Forms\PathTestLogItem.cs" />
@@ -56,20 +62,9 @@
</Compile>
<Compile Include="Models\SimulatorConfig.cs" />
<Compile Include="Models\SimulationState.cs" />
<Compile Include="Forms\SimulatorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SimulatorForm.Designer.cs">
<DependentUpon>SimulatorForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\SimulatorForm.resx">
<DependentUpon>SimulatorForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="build.bat" />
<None Include="packages.config" />
@@ -84,5 +79,10 @@
<Name>AGVMapEditor</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="fMain.resx">
<DependentUpon>fMain.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -56,6 +56,11 @@ namespace AGVSimulator.Forms
listItem.BackColor = Color.LightPink;
}
var dockpos = item.DockingPosition ?? string.Empty;
var targerpos = item.TargetPosition ?? string.Empty;
if (dockpos.Equals("충전기") && targerpos.StartsWith("0015"))
listItem.ForeColor = Color.DarkViolet;
_logListView.Items.Add(listItem);
_logListView.EnsureVisible(_logListView.Items.Count - 1);
}
@@ -172,6 +177,10 @@ namespace AGVSimulator.Forms
SaveToCSV(saveDialog.FileName);
MessageBox.Show($"CSV 파일이 저장되었습니다.\n{saveDialog.FileName}",
"저장 완료", MessageBoxButtons.OK, MessageBoxIcon.Information);
var prc = new System.Diagnostics.Process();
prc.StartInfo = new System.Diagnostics.ProcessStartInfo("explorer", saveDialog.FileName);
prc.Start();
}
catch (Exception ex)
{

View File

@@ -55,6 +55,7 @@ namespace AGVSimulator.Forms
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.launchMapEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.btSelectMapEditor = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.simulationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -85,6 +86,7 @@ namespace AGVSimulator.Forms
this._statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this._coordLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.prb1 = new System.Windows.Forms.ToolStripProgressBar();
this.sbFile = new System.Windows.Forms.ToolStripStatusLabel();
this._controlPanel = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.propertyNode = new System.Windows.Forms.PropertyGrid();
@@ -120,7 +122,7 @@ namespace AGVSimulator.Forms
this._liftDirectionLabel = new System.Windows.Forms.Label();
this._motorDirectionLabel = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.btSelectMapEditor = new System.Windows.Forms.ToolStripMenuItem();
this.button1 = new System.Windows.Forms.Button();
this._menuStrip.SuspendLayout();
this._toolStrip.SuspendLayout();
this._statusStrip.SuspendLayout();
@@ -205,6 +207,13 @@ namespace AGVSimulator.Forms
this.launchMapEditorToolStripMenuItem.Text = "MapEditor 실행(&M)";
this.launchMapEditorToolStripMenuItem.Click += new System.EventHandler(this.OnLaunchMapEditor_Click);
//
// btSelectMapEditor
//
this.btSelectMapEditor.Name = "btSelectMapEditor";
this.btSelectMapEditor.Size = new System.Drawing.Size(221, 22);
this.btSelectMapEditor.Text = "Mapeditor 선택";
this.btSelectMapEditor.Click += new System.EventHandler(this.btSelectMapEditor_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
@@ -434,7 +443,8 @@ namespace AGVSimulator.Forms
this._statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this._statusLabel,
this._coordLabel,
this.prb1});
this.prb1,
this.sbFile});
this._statusStrip.Location = new System.Drawing.Point(0, 689);
this._statusStrip.Name = "_statusStrip";
this._statusStrip.Size = new System.Drawing.Size(1248, 22);
@@ -457,6 +467,12 @@ namespace AGVSimulator.Forms
this.prb1.Name = "prb1";
this.prb1.Size = new System.Drawing.Size(200, 16);
//
// sbFile
//
this.sbFile.Name = "sbFile";
this.sbFile.Size = new System.Drawing.Size(17, 17);
this.sbFile.Text = "--";
//
// _controlPanel
//
this._controlPanel.BackColor = System.Drawing.SystemColors.Control;
@@ -531,6 +547,7 @@ namespace AGVSimulator.Forms
//
// _pathGroup
//
this._pathGroup.Controls.Add(this.button1);
this._pathGroup.Controls.Add(this.btPath2);
this._pathGroup.Controls.Add(this._clearPathButton);
this._pathGroup.Controls.Add(this._targetCalcButton);
@@ -816,12 +833,15 @@ namespace AGVSimulator.Forms
this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// btSelectMapEditor
// button1
//
this.btSelectMapEditor.Name = "btSelectMapEditor";
this.btSelectMapEditor.Size = new System.Drawing.Size(221, 22);
this.btSelectMapEditor.Text = "Mapeditor 선택";
this.btSelectMapEditor.Click += new System.EventHandler(this.btSelectMapEditor_Click);
this.button1.Location = new System.Drawing.Point(21, 201);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(106, 25);
this.button1.TabIndex = 11;
this.button1.Text = "경로 계산2";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// SimulatorForm
//
@@ -937,5 +957,7 @@ namespace AGVSimulator.Forms
private System.Windows.Forms.PropertyGrid propertyNode;
private System.Windows.Forms.Button btPath2;
private System.Windows.Forms.ToolStripMenuItem btSelectMapEditor;
private System.Windows.Forms.ToolStripStatusLabel sbFile;
private System.Windows.Forms.Button button1;
}
}

View File

@@ -108,7 +108,7 @@ namespace AGVSimulator.Forms
}
private UnifiedAGVCanvas _simulatorCanvas;
private AGVPathfinder _advancedPathfinder;
// private AGVPathfinder _advancedPathfinder;
private List<VirtualAGV> _agvList;
private SimulationState _simulationState;
private System.Windows.Forms.Timer _simulationTimer;
@@ -186,6 +186,7 @@ namespace AGVSimulator.Forms
{
_simulatorCanvas = new UnifiedAGVCanvas();
_simulatorCanvas.Dock = DockStyle.Fill;
_simulatorCanvas.Mode = UnifiedAGVCanvas.CanvasMode.Emulator;
// 목적지 선택 이벤트 구독
_simulatorCanvas.NodesSelected += OnTargetNodeSelected;
@@ -875,7 +876,7 @@ namespace AGVSimulator.Forms
try
{
var result = MapLoader.LoadMapFromFile(filePath);
sbFile.Text = filePath;
if (result.Success)
{
Console.WriteLine($"Map File Load : {filePath}");
@@ -1273,10 +1274,24 @@ namespace AGVSimulator.Forms
{
var info = advancedResult.DetailedPath[i];
var rfidId = GetRfidByNodeId(info.NodeId);
var nextRfidId = info.NextNodeId != null ? GetRfidByNodeId(info.NextNodeId).ToString("0000") : "-END-";
var nextRfidId = "";
if (info.NextNode != null && info.NextNode.HasRfid())
{
nextRfidId = info.NextNode.RfidId.ToString("0000");
}
else if (info.NextNode != null)
{
nextRfidId = info.NextNode.Id;
}
else
{
nextRfidId = "-END-";
}
var flags = new List<string>();
if (info.CanRotate) flags.Add("회전가능");
if (info.IsTurn) flags.Add("회전");
if (info.IsDirectionChangePoint) flags.Add("방향전환");
if (info.RequiresSpecialAction) flags.Add($"특수동작:{info.SpecialActionDescription}");
if (info.MagnetDirection != MagnetDirection.Straight) flags.Add($"마그넷:{info.MagnetDirection}");
@@ -1307,6 +1322,8 @@ namespace AGVSimulator.Forms
else if (motorInfo.IsDirectionChangePoint && motorInfo.CanRotate)
motorSymbol += "[↻]";
if (motorInfo.IsTurn) motorSymbol = "[TURN]";
pathWithDetails.Add($"{rfidId}{motorSymbol}");
}
@@ -1524,8 +1541,14 @@ namespace AGVSimulator.Forms
private string GetNodeDisplayName(MapNode node)
{
if (node == null) return "-";
if (node.HasRfid()) return node.RfidId.ToString("0000");
return $"({node.Id})";
var retval = "";
if (node.HasRfid()) retval = node.RfidId.ToString("0000");
else retval = $"({node.Id})";
if (node.DockDirection == DockingDirection.Forward)
retval += "(F)";
else if (node.DockDirection == DockingDirection.Backward)
retval += "(B)";
return retval;
}
/// <summary>
@@ -1564,7 +1587,7 @@ namespace AGVSimulator.Forms
/// UI 상태로부터 테스트 결과 생성 (테스트용)
/// </summary>
private PathTestLogItem CreateTestResultFromUI(MapNode prevNode, MapNode targetNode,
string directionName, (bool result, string message) calcResult)
string directionName, AGVPathResult calcResult)
{
var currentNode = _simulatorCanvas.Nodes.FirstOrDefault(n => n.Id ==
(_agvListCombo.SelectedItem as VirtualAGV)?.CurrentNodeId);
@@ -1575,13 +1598,13 @@ namespace AGVSimulator.Forms
MotorDirection = directionName,
CurrentPosition = GetNodeDisplayName(currentNode),
TargetPosition = GetNodeDisplayName(targetNode),
DockingPosition = (targetNode.StationType == StationType.Charger1 || targetNode.StationType == StationType.Charger2) ? "충전기" : "장비"
DockingPosition = (targetNode.StationType == Station.Charger) ? "충전기" : "장비"
};
if (calcResult.result)
if (calcResult.Success)
{
// 경로 계산 성공 - 현재 화면에 표시된 경로 정보 사용
var currentPath = _simulatorCanvas.CurrentPath;
var currentPath = calcResult;// _simulatorCanvas.CurrentPath;
if (currentPath != null && currentPath.Success)
{
// 도킹 검증
@@ -1591,13 +1614,13 @@ namespace AGVSimulator.Forms
{
logItem.Success = true;
logItem.Message = "성공";
logItem.DetailedPath = currentPath.GetDetailedPathInfo();
logItem.DetailedPath = currentPath.GetDetailedPathInfo(true);
}
else
{
logItem.Success = false;
logItem.Message = $"도킹 검증 실패: {dockingValidation.ValidationError}";
logItem.DetailedPath = currentPath.GetDetailedPathInfo();
logItem.DetailedPath = currentPath.GetDetailedPathInfo(true);
}
}
else
@@ -1611,7 +1634,7 @@ namespace AGVSimulator.Forms
{
// 경로 계산 실패
logItem.Success = false;
logItem.Message = calcResult.message;
logItem.Message = calcResult.Message;
logItem.DetailedPath = "-";
}
@@ -1679,9 +1702,9 @@ namespace AGVSimulator.Forms
logForm.AppendLog("---");
// 각 연결된 노드 쌍에 대해 테스트
foreach (var (nodeA, nodeB) in nodePairs)
foreach (var (direction, directionName) in directions)
{
foreach (var (direction, directionName) in directions)
foreach (var (nodeA, nodeB) in nodePairs)
{
// 취소 확인
if (logForm.CancelRequested)
@@ -1748,19 +1771,22 @@ namespace AGVSimulator.Forms
SetTargetNodeComboBox(dockingTarget.Id);
// 경로 계산 버튼 클릭 (실제 사용자 동작)
//var calcResult = CalcPath();
var startNode = (_startNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var targetNode = (_targetNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
var calcResult = CalcPath_New(startNode, targetNode, this._simulatorCanvas.Nodes, selectedAGV.PrevNode, selectedAGV.PrevDirection);
//// 테스트 결과 생성
//testResult = CreateTestResultFromUI(nodeA, dockingTarget, directionName, calcResult);
testResult = CreateTestResultFromUI(nodeA, dockingTarget, directionName, calcResult);
//// 로그 추가
//logForm.AddLogItem(testResult);
logForm.AddLogItem(testResult);
//// 실패한 경우에만 경로를 화면에 표시 (시각적 확인)
//if (!testResult.Success && _simulatorCanvas.CurrentPath != null)
//{
// _simulatorCanvas.Invalidate();
//}
if (!testResult.Success && _simulatorCanvas.CurrentPath != null)
{
_simulatorCanvas.Invalidate();
}
Application.DoEvents();
});
@@ -1825,8 +1851,15 @@ namespace AGVSimulator.Forms
// 첫 번째 AGV의 다음 행동 예측
var agv = _agvList[0];
var command = agv.Predict();
this.lbPredict.Text = $"Motor:{command.Motor},Magnet:{command.Magnet},Speed:{command.Speed} : {command.Message}";
try
{
var command = agv.Predict();
this.lbPredict.Text = $"Motor:{command.Motor},Magnet:{command.Magnet},Speed:{command.Speed} : {command.Message}";
}catch ( Exception ex)
{
lbPredict.Text = "예측오류" + ex.Message;
}
}
@@ -2090,9 +2123,13 @@ namespace AGVSimulator.Forms
{
try
{
if (_emulatorPort != null && _emulatorPort.IsOpen)
if (_emulatorPort != null)
{
_emulatorPort.Close();
// 이벤트 핸들러 해제 (중복 호출 방지)
_emulatorPort.DataReceived -= OnEmulatorDataReceived;
if (_emulatorPort.IsOpen)
_emulatorPort.Close();
}
_isEmulatorConnected = false;
_connectButton.Text = "Connect";
@@ -2110,6 +2147,8 @@ namespace AGVSimulator.Forms
{
try
{
if (_emulatorPort == null || !_emulatorPort.IsOpen) return;
string data = _emulatorPort.ReadExisting();
_recvBuffer.Append(data);
@@ -2140,6 +2179,11 @@ namespace AGVSimulator.Forms
catch (Exception ex)
{
Console.WriteLine($"Emulator Recv Error: {ex.Message}");
// 수신 중 오류 발생 시 연결 해제 처리 (UI 스레드에서 실행)
this.Invoke(new Action(() =>
{
if (_isEmulatorConnected) DisconnectEmulator();
}));
}
}
@@ -2345,7 +2389,11 @@ namespace AGVSimulator.Forms
private void SendEmulatorStatus()
{
if (_emulatorPort == null || !_emulatorPort.IsOpen) return;
if (_emulatorPort == null || !_emulatorPort.IsOpen)
{
if (_isEmulatorConnected) DisconnectEmulator();
return;
}
var agv = _agvList.FirstOrDefault();
@@ -2398,7 +2446,10 @@ namespace AGVSimulator.Forms
{
_emulatorPort.Write(barr, 0, barr.Length);
}
catch { }
catch
{
if (_isEmulatorConnected) DisconnectEmulator();
}
}
private string CalculateChecksum(string data)
@@ -2504,437 +2555,63 @@ namespace AGVSimulator.Forms
private void btPath2_Click(object sender, EventArgs e)
{
// 1. 기본 정보 획득
if (_startNodeCombo.SelectedItem == null || _startNodeCombo.Text == "선택하세요") SetStartNodeFromAGVPosition();
if (_startNodeCombo.SelectedItem == null || _targetNodeCombo.SelectedItem == null)
{
MessageBox.Show("시작/목표 노드를 확인하세요");
return;
}
//var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
//if (selectedAGV == null) return AGVPathResult.CreateFailure("Virtual AGV 없음");
var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
// 경로계산2 (Gateway Logic)
var rlt = CalcPathGateway();
if (rlt.result == false) MessageBox.Show(rlt.message, "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
var startNode = (_startNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var targetNode = (_targetNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var rlt = CalcPath(startNode, targetNode, this._simulatorCanvas.Nodes, selectedAGV.PrevNode, selectedAGV.PrevDirection);
if (rlt.Success == false) MessageBox.Show(rlt.Message, "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
{
// 8. 적용
ApplyResultToSimulator(rlt, selectedAGV);
UpdateAdvancedPathDebugInfo(rlt);
}
}
/// <summary>
/// 길목(Gateway) 기반 경로 계산
/// 버퍼-버퍼 상태에서는 별도의 추가 로직을 적용합니다
/// </summary>
private (bool result, string message) CalcPathGateway()
public AGVPathResult CalcPath(MapNode startNode, MapNode targetNode, List<MapNode> nodes,
MapNode prevNode, AgvDirection prevDir)
{
// 1. 기본 정보 획득
if (_startNodeCombo.SelectedItem == null || _startNodeCombo.Text == "선택하세요") SetStartNodeFromAGVPosition();
if (_startNodeCombo.SelectedItem == null || _targetNodeCombo.SelectedItem == null) return (false, "시작/목표 노드 선택 필요");
// Core Logic으로 이관됨
var pathFinder = new AGVPathfinder(nodes);
var result = pathFinder.CalculatePath(startNode, targetNode, prevNode, prevDir);
var startNode = (_startNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var targetNode = (_targetNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
if (startNode == null || targetNode == null) return (false, "노드 정보 오류");
if (_advancedPathfinder == null) _advancedPathfinder = new AGVPathfinder(_simulatorCanvas.Nodes);
var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
if (selectedAGV == null) return (false, "Virtual AGV 없음");
var currentAgvDir = selectedAGV.CurrentDirection;
var prevNode = selectedAGV.PrevNode;
var prevDir = selectedAGV.PrevDirection;
// 2. Buffer-to-Buffer 예외 처리
var node05 = FindNode(5); //05~31사이의 노드는 모두 버퍼이다.
var node31 = FindNode(31);
if (node05 == null || node31 == null) return (false, "버퍼구간 노드가 없습니다(05~31)");
var rlt = _advancedPathfinder.FindPathAStar(node05, node31);
if (rlt.Success == false) return (false, "버퍼구간 노드경로 확인 실패(05~31)");
//버퍼구간내에 시작과 종료가 모두 포함되어있다
if (rlt.Path.Contains(startNode) && rlt.Path.Contains(targetNode))
{
return CalcPathBufferToBuffer(startNode, targetNode, prevNode, prevDir, currentAgvDir, selectedAGV);
}
// 3. 목적지별 Gateway 및 진입 조건 확인
var gatewayNode = GetGatewayNode(targetNode);
if (gatewayNode == null)
{
//게이트웨이가 없는 경우라면 목적지가 도킹포인트가 아니므로, a*알골리즘으로 진행 방향만 맟춰서 이동한다
var simplePath = _advancedPathfinder.FindBasicPath(startNode, targetNode, prevNode, prevDir);
if (simplePath.Success)
{
_simulatorCanvas.HighlightNodeId = null; // 일반 경로는 강조 없음
ApplyResultToSimulator(simplePath, selectedAGV);
UpdateAdvancedPathDebugInfo(simplePath);
return (true, "일반 이동 경로(Gateway 없음)");
}
return (false, $"일반 이동 경로 실패: {simplePath.ErrorMessage}");
}
// Gateway Node 찾음
_simulatorCanvas.HighlightNodeId = gatewayNode.Id; // Gateway 강조 설정
// 4. Start -> Gateway 경로 계산 (A*)
var pathToGateway = _advancedPathfinder.FindBasicPath(startNode, gatewayNode, prevNode, prevDir);
if (!pathToGateway.Success) return (false, $"Gateway({gatewayNode.ID2})까지 경로 실패: {pathToGateway.ErrorMessage}");
//마지막경로는 게이트웨이이므로 제거하낟.(260113)
if (pathToGateway.Path.Count > 1 && pathToGateway.Path.Last().Id == gatewayNode.Id)
{
pathToGateway.Path.RemoveAt(pathToGateway.Path.Count - 1);
pathToGateway.DetailedPath.RemoveAt(pathToGateway.DetailedPath.Count - 1);
}
// 5. Gateway -> Target 경로 계산 (회차 패턴 및 최종 진입 포함)
MapNode GateprevNode = pathToGateway.Path.Last();
NodeMotorInfo GatePrevDetail = pathToGateway.DetailedPath.Last();
var arrivalOrientation = GatePrevDetail.MotorDirection;
//아래코드오류발생함
var gatewayPathResult = GetPathFromGateway(gatewayNode, targetNode, GateprevNode, arrivalOrientation);
if (!gatewayPathResult.Success) return (false, $"{gatewayPathResult.ErrorMessage}");
AGVPathResult finalPath = pathToGateway;
finalPath = CombinePaths(finalPath, gatewayPathResult);
// 8. 적용
ApplyResultToSimulator(finalPath, selectedAGV);
UpdateAdvancedPathDebugInfo(finalPath);
return (true, "성공");
}
/// <summary>
/// 노드를 찾기위한 함수
/// </summary>
/// <param name="rfid"></param>
/// <returns></returns>
private MapNode FindNode(ushort rfid)
{
return _simulatorCanvas.Nodes.FirstOrDefault(n => n.RfidId == rfid);
//게이트웨이노드를 하이라이트강조 한단
this._simulatorCanvas.HighlightNodeId = (result.Gateway?.Id ?? string.Empty);
return result;
}
/// <summary>
/// 노드를 찾기위한 함수
/// 길목(Gateway) 기반 경로 계산
/// 버퍼-버퍼 상태에서는 별도의 추가 로직을 적용합니다
/// </summary>
/// <param name="nodeid"></param>
/// <returns></returns>
private MapNode FindNode(string nodeid)
public AGVPathResult CalcPath_New(MapNode startNode, MapNode targetNode, List<MapNode> nodes,
MapNode prevNode, AgvDirection prevDir)
{
return _simulatorCanvas.Nodes.FirstOrDefault(n => n.Id == nodeid);
// Core Logic으로 이관됨
var pathFinder = new AGVPathfinder(nodes);
var result = pathFinder.CalculateScriptedPath(startNode, targetNode, prevNode, prevDir);
//게이트웨이노드를 하이라이트강조 한단
this._simulatorCanvas.HighlightNodeId = (result.Gateway?.Id ?? string.Empty);
return result;
}
/// <summary>
/// Gateway 도착 후, Target까지의 경로(회차 및 최종진입 포함)를 계산합니다.
/// </summary>
/// <param name="GTNode">게이트웨이 노드값(현재노드값)</param>
/// <param name="targetNode">최종 목표값</param>
/// <param name="PrevNode">게이트웨이 진입 전 노드</param>
/// <param name="PrevDirection">게이트웨이 진입 전 모터방향</param>
/// <returns></returns>
private AGVPathResult GetPathFromGateway(MapNode GTNode, MapNode targetNode, MapNode PrevNode, AgvDirection PrevDirection)
{
AGVPathResult resultPath = null;
//게이트웨이 진입 한 방향을 보고. 목적지와 도킹방향이 일치하는지 결정한다.
var deltaX = GTNode.Position.X - PrevNode.Position.X;
var isMonitorLeft = false;
bool requiredDir = false;
if (deltaX > 0) //게이트웨이가 우측에 있다
{
//이떄 모터방향이 후진이라면 모니터는 왼쪽이고, 반대는 오른쪽이다
isMonitorLeft = PrevDirection == AgvDirection.Backward;
}
else
{
isMonitorLeft = PrevDirection == AgvDirection.Forward;
}
//로더는 상/하 개념으로 처리해야한다.X축이아닌 Y축을 봐야한다.
if (targetNode.StationType == StationType.Loader || targetNode.StationType == StationType.Charger2)
{
deltaX = GTNode.Position.Y - PrevNode.Position.Y;
if (deltaX < 0) isMonitorLeft = PrevDirection == AgvDirection.Backward;
else isMonitorLeft = PrevDirection == AgvDirection.Forward;
}
switch (targetNode.StationType)
{
case StationType.Loader:
case StationType.Charger2:
case StationType.Charger1:
case StationType.UnLoader:
case StationType.Clearner:
case StationType.Buffer:
//버퍼는 모니터가 왼쪽에 있으면 안된다.
//충전기1만 전진 도킹을 한다.
List<string> turnPatterns = new List<string>();
AGVPathResult rlt1 = new AGVPathResult();
rlt1.Success = true;
//목적지까지 바로 계산한다
var pathtarget = _advancedPathfinder.FindBasicPath(GTNode, targetNode, PrevNode, AgvDirection.Backward);
if (targetNode.DockDirection == DockingDirection.Backward && isMonitorLeft)
{
//턴을 하는
turnPatterns = GetTurnaroundPattern(GTNode, targetNode);
if (turnPatterns == null || turnPatterns.Any() == false) return new AGVPathResult { Success = false, ErrorMessage = $"회차 패턴 없음: Dir {PrevDirection}" };
foreach (var item in turnPatterns)
{
var rfidvalue = ushort.Parse(item.Substring(0, 4));
var node = _simulatorCanvas.Nodes.FirstOrDefault(t => t.RfidId == rfidvalue);
//경로노드추가
rlt1.Path.Add(node);
//Detail 정보도 추가한다.
AgvDirection nodedir = item.Substring(4, 1) == "F" ? AgvDirection.Forward : AgvDirection.Backward;
MagnetDirection magnet = MagnetDirection.Straight;
var magchar = item.Substring(5, 1);
if (magchar == "L") magnet = MagnetDirection.Left;
else if (magchar == "R") magnet = MagnetDirection.Right;
rlt1.DetailedPath.Add(new NodeMotorInfo(rlt1.DetailedPath.Count, node.Id, node.RfidId, nodedir, null, magnet)
{
Speed = SpeedLevel.L,
});
}
//시작위치가 겹치므로 제거해줘야하낟.
if (pathtarget.DetailedPath.First().NodeId != rlt1.DetailedPath.Last().NodeId ||
pathtarget.DetailedPath.First().MotorDirection != rlt1.DetailedPath.Last().MotorDirection)
{
new AGVPathResult { Success = false, ErrorMessage = $"게이트웨이 턴 마지막 주소와, 이 후 주소의 시작 노드ID가 일치하지 않습니다" };
}
pathtarget.Path.RemoveAt(0);
pathtarget.DetailedPath.RemoveAt(0);
}
var lastpath = CombinePaths(rlt1, pathtarget);
return lastpath;
default:
throw new Exception("ASdf");
}
return null;
}
/// <summary>
/// 지정한 노드의 게이트웨이를 반환합니다.
/// 도킹노드가 아닐경우 NULL이 반환됩니다.
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private MapNode GetGatewayNode(MapNode node)
{
var rfid = 0;
if (node.RfidId == 1) rfid = 10;
if (node.RfidId == 15) rfid = 9;
if (node.RfidId == 11) rfid = 6;
if (node.RfidId == 8) rfid = 13;
if (node.RfidId == 19) rfid = 13;
if (node.StationType == StationType.Buffer) rfid = 6;
if (rfid == 0) return null;
return this._simulatorCanvas.Nodes.FirstOrDefault(t => t.RfidId == rfid);
}
private AgvDirection GetRequiredGatewayDirection(string gatewayLogId)
{
switch (gatewayLogId)
{
case "0010": return AgvDirection.Backward;
case "0009": return AgvDirection.Forward;
case "0006": return AgvDirection.Backward;
case "0013": return AgvDirection.Backward;
default: return AgvDirection.Forward;
}
}
/// <summary>
/// 대상노드와 게이트웨이노드를 가지고 턴 노드값을 반환합니다
/// (이 값은 하드코딩 되어있음)
/// </summary>
/// <param name="gatewayNode"></param>
/// <param name="targetNode"></param>
/// <returns></returns>
private List<string> GetTurnaroundPattern(MapNode gatewayNode, MapNode targetNode)
{
switch (gatewayNode.RfidId)
{
case 6:
//버퍼와 11을 다르게하낟.
if (targetNode.StationType == StationType.Buffer)
{
return new List<string> { "0006BL", "0007FS", "0013BL", "0006BL" };
}
else
{
return new List<string> { "0006BL", "0007FS", "0013BL", "0006BS" };
}
case 9: return new List<string> { "0009FL", "0010BS", "0007FL", "0009FS" };
case 10: return new List<string> { "0010BR", "0009FR", "0007BS", "0010BS" };
case 13: return new List<string> { "0013BL", "0006FL", "0007BS", "0013BS" };
default: return null;
}
}
private (bool result, string message) CalcPathBufferToBuffer(MapNode start, MapNode target, MapNode prev, AgvDirection prevDir, AgvDirection currentDir, VirtualAGV agv)
{
// Monitor Side 판단 로직
// 현재 AGV의 물리적 방향(Monitor Side)이 "Right" 상태여야 버퍼 진입이 용이하다고 가정.
// Monitor Left 상태(부적절한 방향)라면 Gateway로 탈출해야 함.
// 이동 벡터 X 변화량
// prev가 없거나 start와 같으면 이동 방향을 알 수 없음 -> 이 경우 보수적으로 기존 로직(Backward면 탈출) 따름
int deltaX = 0;
if (prev == null) return (false, "이전 노드 정보가 없습니다");
else deltaX = start.Position.X - prev.Position.X;
bool isMonitorLeft = false;
if (deltaX > 0) // 오른쪽(Forward)으로 이동해 옴 (예: 2 -> 4)
{
// 이동방향(Right) + 전진(F) => Monitor Right (Good)
// 이동방향(Right) + 후진(B) => Monitor Left (Bad)
isMonitorLeft = (prevDir == AgvDirection.Backward);
}
else if (deltaX < 0) // 왼쪽(Reverse)으로 이동해 옴 (예: 4 -> 2)
{
// 이동방향(Left) + 전진(F) => Monitor Left (Bad)
// 이동방향(Left) + 후진(B) => Monitor Right (Good)
isMonitorLeft = (prevDir == AgvDirection.Forward);
}
else // 제자리 또는 수직 이동
{
// 판단 불가 시 기존 로직(Backward면 Gateway) 유지
return (false, "이전 노드와의 방향을 알 수 없습니다");
}
if (isMonitorLeft)
{
// Monitor Left 상태 (방향 불일치) -> Gateway로 탈출
var GateWayNode = FindNode(6);
var escPath = _advancedPathfinder.FindBasicPath(start, GateWayNode, prev, prevDir);
if (!escPath.Success) return (false, "버퍼 탈출 경로 실패");
var lastNode = escPath.Path.Last(); // Should be GW6
var lastPrev = escPath.Path[escPath.Path.Count - 2];
var lastDir = escPath.DetailedPath.Last().MotorDirection;
// Gateway 도착 후, Target(Buffer)으로 이동
// 여기서부터는 "Monitor Right" 로직(즉, 적절한 방향 진입)을 적용합니다.
// 6번에서 Target이 왼쪽이면 Direct(Backward), 오른쪽이면 Overshoot(Forward->Backward)
bool isTargetLeftOfGW = target.Position.X < GateWayNode.Position.X;
AGVPathResult entryPath = null;
//게이트웨이까지 후진으로 이동했다면 모니터방향이 오른쪽이다 => 방향전환필요
var gateToTarget = GetPathFromGateway(GateWayNode, target, lastPrev, lastDir);
escPath.Path.RemoveAt(escPath.Path.Count - 1);
escPath.DetailedPath.RemoveAt(escPath.DetailedPath.Count - 1);
var final = CombinePaths(escPath, gateToTarget);
ApplyResultToSimulator(final, agv);
UpdateAdvancedPathDebugInfo(final);
return (true, "버퍼 재진입(탈출후)");
}
else
{
// Monitor Right 상태 (방향 일치) -> 직접 진입 또는 Overshoot
bool isTargetLeft = target.Position.X < start.Position.X;
if (isTargetLeft)
{
var directPath = _advancedPathfinder.FindBasicPath(start, target, prev, AgvDirection.Backward);
ApplyResultToSimulator(directPath, agv);
UpdateAdvancedPathDebugInfo(directPath);
return (true, "버퍼 좌측이동(직접진입)");
}
else
{
//대상이 나보다 우측에 있으니 RFID값이 읽어지는 위치까지 이동후에 다시 반대방향으로 마크스탑 해야 함
//그냥 대상 노드까지 이동을 한다.. RFID값이 실제 멈추는 위치 이전에 있으니 그곳까지 이동하고 역방향 마크스탑하면 동일한 위치이다. 위 식은 그 이전노드까지 확실하게 이동하는 코드이다
//var overshootNode = target.ConnectedMapNodes.OrderByDescending(n => n.Position.X).FirstOrDefault();
//if (overshootNode == null || overshootNode.Position.X <= target.Position.X)
// return (false, "Overshoot 공간 부족");
var path1 = _advancedPathfinder.FindBasicPath(start, target, prev, AgvDirection.Forward);
if (path1.Path.Count < 2) return (false, "Overshoot 경로 생성 실패");
//목표에서 방향바꿔 마크스탑을 해야한다
path1.Path.Add(path1.Path.Last());
//디테일은 방향바꿔서 추가 필요(속도는 저속처리해준다)
var lastDefailt = path1.DetailedPath.Last();
path1.DetailedPath.Add(new NodeMotorInfo(lastDefailt.seq + 1, lastDefailt.NodeId, lastDefailt.RfidId, AgvDirection.Backward)
{
Speed = SpeedLevel.L,
IsPass = false,
});
//var p1Last = path1.Path.Last();
//var p1Prev = path1.Path[path1.Path.Count > 1 ? path1.Path.Count - 2 : 0]; // Safety check
//var p1Dir = path1.DetailedPath.Last().MotorDirection;
//var path2 = _advancedPathfinder.FindPath(start, target, p1Last, p1Dir, AgvDirection.Backward);
//if (path2.Success && path2.DetailedPath.Last().NodeId == target.Id)
// path2.DetailedPath = path2.DetailedPath.Take(path2.DetailedPath.Count - 1).ToList();
//var final = CombinePaths(path1, path2);
ApplyResultToSimulator(path1, agv);
UpdateAdvancedPathDebugInfo(path1);
return (true, "버퍼 우측(Overshoot)");
}
}
}
/// <summary>
/// p1+p2
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
private AGVPathResult CombinePaths(AGVPathResult p1, AGVPathResult p2)
{
var res = new AGVPathResult();
res.Success = true;
foreach (var item in p1.Path)
{
res.Path.Add(item);
}
foreach (var item in p2.Path)
{
res.Path.Add(item);
}
foreach (var item in p1.DetailedPath)
{
var maxseq = res.DetailedPath.Count == 0 ? 0 : res.DetailedPath.Max(t => t.seq);
item.seq = maxseq + 1;
res.DetailedPath.Add(item);
}
foreach (var item in p2.DetailedPath)
{
var maxseq = res.DetailedPath.Count == 0 ? 0 : res.DetailedPath.Max(t => t.seq);
item.seq = maxseq + 1;
res.DetailedPath.Add(item);
}
return res;
}
private void ApplyResultToSimulator(AGVPathResult result, VirtualAGV agv)
{
_simulatorCanvas.CurrentPath = result;
@@ -2968,5 +2645,33 @@ namespace AGVSimulator.Forms
}
}
}
private void button1_Click(object sender, EventArgs e)
{
// 1. 기본 정보 획득
if (_startNodeCombo.SelectedItem == null || _startNodeCombo.Text == "선택하세요") SetStartNodeFromAGVPosition();
if (_startNodeCombo.SelectedItem == null || _targetNodeCombo.SelectedItem == null)
{
MessageBox.Show("시작/목표 노드를 확인하세요");
return;
}
//var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
//if (selectedAGV == null) return AGVPathResult.CreateFailure("Virtual AGV 없음");
var selectedAGV = _agvListCombo.SelectedItem as VirtualAGV;
// 경로계산2 (Gateway Logic)
var startNode = (_startNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var targetNode = (_targetNodeCombo.SelectedItem as ComboBoxItem<MapNode>)?.Value;
var rlt = CalcPath_New(startNode, targetNode, this._simulatorCanvas.Nodes, selectedAGV.PrevNode, selectedAGV.PrevDirection);
if (rlt.Success == false) MessageBox.Show(rlt.Message, "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
{
// 8. 적용
ApplyResultToSimulator(rlt, selectedAGV);
UpdateAdvancedPathDebugInfo(rlt);
}
}
}
}

13
AGVLogic/EnigProtocol/.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
obj
bin
*.user
*.v12
*.suo
.git
.vs
Debug
__vm
*.pdb
desktop.ini
packages
~*.xlsx

View File

@@ -0,0 +1,53 @@
using Xunit;
using ENIG;
namespace ENIGProtocol.Tests
{
public class EEProtocolTests
{
[Fact]
public void TestCRC16Calculation()
{
// 테스트 데이터
byte[] testData = new byte[] { 0x02,0x00,0xFF }; //payload에는 stx, len, ... crc,etx 는 제외한다
// CRC16 계산
var protocol = new EEProtocol();
ushort crc = protocol.CalculateCRC16(testData);
// 예상 결과와 비교
Assert.Equal(0x1789, crc);
}
[Fact]
public void TestPacketCreation()
{
// 패킷 생성 테스트
var protocol = new EEProtocol();
byte[] packet = protocol.CreatePacket(0x01, 0x02, new byte[] { 0x03, 0x04 });
// 패킷 구조 검증
Assert.Equal(0x02, packet[0]); // STX
Assert.Equal(0x04, packet[1]); // Length
Assert.Equal(0x01, packet[2]); // ID
Assert.Equal(0x02, packet[3]); // Command
Assert.Equal(0x03, packet[4]); // Data[0]
Assert.Equal(0x04, packet[5]); // Data[1]
}
[Fact]
public void TestPacketParsing()
{
// 패킷 파싱 테스트
var protocol = new EEProtocol();
//byte[] testPacket = new byte[] { 0x02, 0x04, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x03 };
byte[] testPacket = new byte[] { 0x02, 0x02, 0x00, 0xFF, 0x89, 0x17, 0x03 };
bool result = protocol.ParsePacket(testPacket);
Assert.True(result);
}
}
}

View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\enigprotocol\enigprotocol.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,10 @@
namespace ENIGProtocol.Tests;
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}

View File

@@ -0,0 +1,43 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 15 for Windows Desktop
VisualStudioVersion = 15.0.28307.1000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "솔루션 항목", "솔루션 항목", "{0A11874A-E5C6-4170-9787-1FFF7AF0D289}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
ReadMe.MD = ReadMe.MD
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleProject", "sample\SampleProject.csproj", "{FAB31C8A-7DCF-4152-8A82-76F3C10BABA4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENIGProtocol.Tests", "ENIGProtocol.Tests\ENIGProtocol.Tests.csproj", "{3A677629-1F08-49B2-BC75-58282E439FD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENIGProtocol", "enigprotocol\ENIGProtocol.csproj", "{499D8912-4B96-41E5-A70D-CFE797883D65}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAB31C8A-7DCF-4152-8A82-76F3C10BABA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAB31C8A-7DCF-4152-8A82-76F3C10BABA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAB31C8A-7DCF-4152-8A82-76F3C10BABA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAB31C8A-7DCF-4152-8A82-76F3C10BABA4}.Release|Any CPU.Build.0 = Release|Any CPU
{3A677629-1F08-49B2-BC75-58282E439FD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A677629-1F08-49B2-BC75-58282E439FD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A677629-1F08-49B2-BC75-58282E439FD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A677629-1F08-49B2-BC75-58282E439FD4}.Release|Any CPU.Build.0 = Release|Any CPU
{499D8912-4B96-41E5-A70D-CFE797883D65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{499D8912-4B96-41E5-A70D-CFE797883D65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{499D8912-4B96-41E5-A70D-CFE797883D65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{499D8912-4B96-41E5-A70D-CFE797883D65}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {07331835-C46C-4B93-965F-AD2714F97F88}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,246 @@
# ENIG Protocol
ENIG 프로토콜 통신 라이브러리
**Explanation of the README Content:**
1. **Title and Overview:** Clearly states the purpose of the library.
2. **Key Components:** Explains the main building blocks:
* `DeviceType` enum: Lists the device types.
* `Packet` class: Describes the packet structure.
* `EEProtocol` class: Explains its role in packet handling.
3. **Key Features:** Details the core functionalities of the `EEProtocol` class:
* Packet creation.
* Packet parsing.
* Data reception.
* Event-driven nature.
* CRC16 calculation.
4. **Usage:** Provides code examples for:
* Creating a packet.
* Parsing a packet.
* Processing received data.
5. **Error Handling:** Explains how the library handles invalid data and incomplete packets.
6. **Dependencies:** Lists any required frameworks or libraries.
7. **License:** Placeholder for the project's license.
This README provides a comprehensive overview of the `ENIGProtocol` library, making it easy for other developers to understand and use it. I hope this is helpful!
## 개발 환경
- Frameworks : .NET Standard 2.0
- Visual Studio 2022 또는 Visual Studio Code
## 프로젝트 구조
- `EEProtocol.cs`: ENIG 프로토콜 구현
- `EEProtocolTests.cs`: 단위 테스트 코드
- `Sample`: C# Winform 샘플 프로젝트
## 장비 목록
```
public enum DeviceType : byte
{
ACS = 0,
AGV1 = 10+1,
AGV2 = 10+2,
BUFFER1 = 20+1,
BUFFER2 = 20+2,
BUFFER3 = 20+3,
BUFFER4 = 20+4,
BUFFER5 = 20+5,
DOOR = 30,
}
```
public enum DeviceAlias : byte
{
B1 = 20 + 1, //BUFFER1 ~ 5
B2 = 20 + 2,
B3 = 20 + 3,
B4 = 20 + 4,
B5 = 20 + 5,
C1 = 40 + 1, //충전소 1
C2 = 40 + 2, //충전소 2
C3 = 40 + 3, //충전소 3
C4 = 40 + 4, //충전소 4
E1 = 90 + 1, //장비1 (SSOTRON Loader)
E2 = 90 + 2, //장비2 (TOPS ENIG)
E3 = 90 + 3, //장비3 (SSOTRON DIVERTER)
}
//11번 AGV야! BUFFER1로 이동해라!
//0x02 0x03 0x0B 0x6B 0x42 0x31 {CRC} 0x03
### 기본 패킷 구조
```
[STX][LEN][ID][CMD][DATA][CRC16][ETX]
```
- **STX (Start of Text)**: 0x02
- **LEN (Length)**: 데이터 길이 (1바이트) = {CMD+DATA}
- **ID (Client ID)**: 데이터 길이 (1바이트) : 디바이스식별코드(=DeviceType)
- **CMD (Command)**: 명령어 코드 (1바이트)
- **DATA**: 명령어에 따른 데이터 (가변 길이)
- **CRC16**: 데이터 무결성 검사 (2바이트)
- **ETX (End of Text)**: 0x03
### 통신 방향 (호스트=ACS, 장비=agv,buffer,door)
- H -> E: 호스트에서 장비로 전송
- E -> H: 장비에서 호스트로 전송
### 명령어 목록
1. **ACS (AGV Control System)**
2. **Buffer**
- E -> H | cmd(3): 상태 (data len=1 : 0=카트없음, 1=카트있음, 2=바쁨, 3=알수없음, 255=오류)
- H -> E | cmd(1): Lock
- Target[1] = {DeviceType}
- H -> E | cmd(2): UnLock
- Target[1] = {DeviceType}
3. **AGV**
- H -> E | Move : cmd(100) : 대상태그까지 이동(자동이동)
- Target[1] = {DeviceType}
- TagID[4] = "0000"
- H -> E | Stop : cmd(101) : 멈춤
- H -> E | Reset : cmd(102) : 오류 소거
- H -> E | SetCurrent : cmd(103) : 현재위치설정
- Target[1] = {DeviceType}
- TagID[4] = "0000"
- H -> E | MoveManual : cmd(104) : 메뉴얼이동
- Target[1] = {DeviceType}
- Direction[1] : 0=Backward, 1=Forward, 2=TurnLeft, 3=TurnRight
- Speed[1] : 0=Slow, 1=Normal, 2=Fast
- H -> E | MarkStop : cmd(105) : 마크센서스톱
- Target[1] = {DeviceType}
- H -> E | Lift Control : cmd(106) : 리프트제어
- Target[1] = {DeviceType}
- Action[1] : 0=STOP, 1=UP, 2=DOWN
- H -> E | Move : cmd(107) : 대상별칭까지 이동(자동이동)
- Target[1] = {DeviceType}
- AliasName[n] = ".....
- H -> E | MoveAuto : cmd(108) : 자동이동
- Target[1] = {DeviceType}
- MotDirection[1] : 0=Backward, 1=Forward
- MagnetDirection[1] : 0=Straight,1=Left, 2=Right
- Speed[1] : 0=Slow, 1=Normal, 2=Fast
- H -> E | Charge On: cmd(109) : 충전실행(충전기 이동 후 자동 충전 진행)
- Target[1] = {DeviceType}
- Action[1] : 0=Charge Off, 1=Charge On
- E -> H | Move Complete : cmd(1) : 목적지이동완료 후 전송
- TagID[4] : "0000"
- E -> H | TagID Received : cmd(2) : 태그값 인식시 전송
- TagID[4] : "0000"
- E -> H | Status : cmd(3)
- Mode[1] : 0=manual, 1=auto
- RunSt[1] : 0=stop, 1=run, 2=error
- Diection[1] : 0=straight, 1=left, 2=right, 3=markstop
- Inposition[1] : 0=off, 1=on : 목적위치에 도달완료 시 설정 이동 이동시 OFF됨
- ChargeSt[1] : 0=off, 1=on
- CartSt[1] : 0=off, 1=on, 2=unknown
- LiftSt[1] : 0=down , 1=up, 2=unknown
- LastTag[4] : "0000"
- CurrentPath[1] : Path ID , 0=미설정, 1~255(순차증가)
4. **Door**
- H -> E | cmd(1): 출입문 열기
- H -> E | cmd(2): 출입문 닫기
- E -> H | cmd(3): 출입문 상태 (data len=1 : 0=닫힘, 1=열림, 2=바쁨, 3=알수없음, 255=오류)
### CRC16 계산
- CRC16 다항식 사용
- 초기값: 0xFFFF
- 데이터 무결성 검증에 사용
#### CRC-16 테이블 값
```
0x0000, 0x408E, 0x73EF, 0x3361, 0x152D, 0x55A3, 0x66C2, 0x264C,
0x2A5A, 0x6AD4, 0x59B5, 0x193B, 0x3F77, 0x7FF9, 0x4C98, 0x0C16,
0x54B4, 0x143A, 0x275B, 0x67D5, 0x4199, 0x0117, 0x3276, 0x72F8,
0x7EEE, 0x3E60, 0x0D01, 0x4D8F, 0x6BC3, 0x2B4D, 0x182C, 0x58A2,
0x5B9B, 0x1B15, 0x2874, 0x68FA, 0x4EB6, 0x0E38, 0x3D59, 0x7DD7,
0x71C1, 0x314F, 0x022E, 0x42A0, 0x64EC, 0x2462, 0x1703, 0x578D,
0x0F2F, 0x4FA1, 0x7CC0, 0x3C4E, 0x1A02, 0x5A8C, 0x69ED, 0x2963,
0x2575, 0x65FB, 0x569A, 0x1614, 0x3058, 0x70D6, 0x43B7, 0x0339,
0x45C5, 0x054B, 0x362A, 0x76A4, 0x50E8, 0x1066, 0x2307, 0x6389,
0x6F9F, 0x2F11, 0x1C70, 0x5CFE, 0x7AB2, 0x3A3C, 0x095D, 0x49D3,
0x1171, 0x51FF, 0x629E, 0x2210, 0x045C, 0x44D2, 0x77B3, 0x373D,
0x3B2B, 0x7BA5, 0x48C4, 0x084A, 0x2E06, 0x6E88, 0x5DE9, 0x1D67,
0x1E5E, 0x5ED0, 0x6DB1, 0x2D3F, 0x0B73, 0x4BFD, 0x789C, 0x3812,
0x3404, 0x748A, 0x47EB, 0x0765, 0x2129, 0x61A7, 0x52C6, 0x1248,
0x4AEA, 0x0A64, 0x3905, 0x798B, 0x5FC7, 0x1F49, 0x2C28, 0x6CA6,
0x60B0, 0x203E, 0x135F, 0x53D1, 0x759D, 0x3513, 0x0672, 0x46FC,
0x7979, 0x39F7, 0x0A96, 0x4A18, 0x6C54, 0x2CDA, 0x1FBB, 0x5F35,
0x5323, 0x13AD, 0x20CC, 0x6042, 0x460E, 0x0680, 0x35E1, 0x756F,
0x2DCD, 0x6D43, 0x5E22, 0x1EAC, 0x38E0, 0x786E, 0x4B0F, 0x0B81,
0x0797, 0x4719, 0x7478, 0x34F6, 0x12BA, 0x5234, 0x6155, 0x21DB,
0x22E2, 0x626C, 0x510D, 0x1183, 0x37CF, 0x7741, 0x4420, 0x04AE,
0x08B8, 0x4836, 0x7B57, 0x3BD9, 0x1D95, 0x5D1B, 0x6E7A, 0x2EF4,
0x7656, 0x36D8, 0x05B9, 0x4537, 0x637B, 0x23F5, 0x1094, 0x501A,
0x5C0C, 0x1C82, 0x2FE3, 0x6F6D, 0x4921, 0x09AF, 0x3ACE, 0x7A40,
0x3CBC, 0x7C32, 0x4F53, 0x0FDD, 0x2991, 0x691F, 0x5A7E, 0x1AF0,
0x16E6, 0x5668, 0x6509, 0x2587, 0x03CB, 0x4345, 0x7024, 0x30AA,
0x6808, 0x2886, 0x1BE7, 0x5B69, 0x7D25, 0x3DAB, 0x0ECA, 0x4E44,
0x4252, 0x02DC, 0x31BD, 0x7133, 0x577F, 0x17F1, 0x2490, 0x641E,
0x6727, 0x27A9, 0x14C8, 0x5446, 0x720A, 0x3284, 0x01E5, 0x416B,
0x4D7D, 0x0DF3, 0x3E92, 0x7E1C, 0x5850, 0x18DE, 0x2BBF, 0x6B31,
0x3393, 0x731D, 0x407C, 0x00F2, 0x26BE, 0x6630, 0x5551, 0x15DF,
0x19C9, 0x5947, 0x6A26, 0x2AA8, 0x0CE4, 0x4C6A, 0x7F0B, 0x3F85,
```
#### CRC16 계산 테이블 생성 코드
```csharp
const ushort polynomial = 0x7979;
ushort[] CRC16_TABLE = new ushort[256];
for (ushort i = 0; i < CRC16_TABLE.Length; i++)
{
ushort value = 0;
ushort temp = i;
for (byte j = 0; j < 8; j++)
{
if (((value ^ temp) & 0x0001) != 0)
{
value = (ushort)((value >> 1) ^ polynomial);
}
else
{
value >>= 1;
}
temp >>= 1;
}
CRC16_TABLE[i] = value;
}
```
#### CRC16 계산 예시
```csharp
ushort CalculateCRC16(byte[] data)
{
ushort crc = 0xFFFF;
for (int i = 0; i < data.Length; i++)
{
byte index = (byte)(crc ^ data[i]);
crc = (ushort)((crc >> 8) ^ CRC16_TABLE[index]);
}
return crc;
}
```
## 라이센스

View File

@@ -0,0 +1,8 @@
################################################################################
# 이 .gitignore 파일은 Microsoft(R) Visual Studio에서 자동으로 만들어졌습니다.
################################################################################
/obj
/bin
/.vs
/.git

View File

@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ENIGProtocol
{
/// <summary>
/// host -> eq
/// </summary>
public enum AGVCommandHE : byte
{
Goto = 100,
Stop = 101,
Reset = 102,
SetCurrent = 103,
Manual = 104,
MarkStop = 105,
LiftControl = 106,
GotoAlias = 107,
AutoMove = 108,
ChargeControl = 109,
Charger = 112,
LTurn = 113,
RTurn = 114,
LTurn180 = 115,
RTurn180 = 116,
PickOnEnter = 117,
PickOffEnter = 118,
PickOnExit = 119,
PickOffExit = 120,
}
/// <summary>
/// eq -> host
/// </summary>
public enum AGVCommandEH : byte
{
Error = 1,
Arrived = 2,
ReadRFID = 3,
ActionComplete=4,
Status = 9,
}
public enum AGVErrorCode : byte
{
None = 0,
PredictFix,
TurnTimeout,
TurnError,
EmptyNode,
Goto,
ManualMode,
UnknownCommand,
UnknownAlias,
// Operational Errors
CART_EXIST,
MARK_TIMEOUT,
MARK_SENSOR_FAIL,
LIFT_ERROR,
AGV_SPEED_SET_FAIL,
AGV_RUN_FAIL,
AGV_STOP_FAIL,
PATH_INTEGRITY_FAIL,
TURN_FAIL,
NO_CHARGEPOINT,
NOTSET_CHARGEPOINT,
ALREADY_CHARGE,
CHARGE_RETRY_OVER,
MAGNET_ON_ERROR,
MAGNET_OF_ERROR,
BUFFER_NOT_COMPLETE,
MARK_STOP_FAIL,
LIDAR_STOP,
NOT_BUFFERPOINT,
NOT_EQUIPMENTPOINT,
PATH_COMPLETE_INTEGRITY_FAIL,
UPDATEMOTION_TIMEOUT
}
public static class AGVUtility
{
/// <summary>
/// 에러코드에 해당하는 오류메세지를 반환 합니다
/// </summary>
/// <param name="ecode"></param>
/// <returns></returns>
public static string GetAGVErrorMessage(AGVErrorCode ecode)
{
switch (ecode)
{
case AGVErrorCode.None: return "No Error";
case AGVErrorCode.PredictFix: return "이동 예측이 동작하지 않습니다";
case AGVErrorCode.TurnTimeout: return "회전작업 시간초과";
case AGVErrorCode.TurnError: return "회전작업이 완료되지 않았습니다";
case AGVErrorCode.EmptyNode: return "노드정보를 찾을 수 없습니다";
case AGVErrorCode.Goto: return "이동 명령 오류";
case AGVErrorCode.ManualMode: return "자동운전 상태가 아닙니다";
case AGVErrorCode.UnknownCommand: return "알수 없는 명령입니다";
case AGVErrorCode.UnknownAlias: return "알수 없는 별칭 입니다";
case AGVErrorCode.CART_EXIST: return "카트 감지 센서 오류";
case AGVErrorCode.MARK_TIMEOUT: return "마크 정지 신호 시간초과";
case AGVErrorCode.MARK_SENSOR_FAIL: return "마크 센서 미감지";
case AGVErrorCode.LIFT_ERROR: return "리프트 동작 오류";
case AGVErrorCode.AGV_SPEED_SET_FAIL: return "AGV 속도 설정 실패";
case AGVErrorCode.AGV_RUN_FAIL: return "AGV 구동 실패";
case AGVErrorCode.AGV_STOP_FAIL: return "AGV 정지 실패";
case AGVErrorCode.PATH_INTEGRITY_FAIL: return "경로 무결성 검증 실패";
case AGVErrorCode.TURN_FAIL: return "턴 동작 실패";
case AGVErrorCode.NO_CHARGEPOINT: return "충전 위치 아님";
case AGVErrorCode.NOTSET_CHARGEPOINT: return "충전기 노드 미설정";
case AGVErrorCode.ALREADY_CHARGE: return "이미 충전 중 상태임";
case AGVErrorCode.CHARGE_RETRY_OVER: return $"충전명령 재전송 횟수 초과";
case AGVErrorCode.NOT_BUFFERPOINT: return "현재 위치가 버퍼가 아닙니다";
case AGVErrorCode.NOT_EQUIPMENTPOINT: return "현재 위치가 장비 노드가 아닙니다";
case AGVErrorCode.PATH_COMPLETE_INTEGRITY_FAIL: return "목적지 도착 완료 했으나 노드 혹은 방향이 일치지하지 않습니다";
default: return ecode.ToString();
}
}
}
}

View File

@@ -0,0 +1,235 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ENIG
{
// 장비 타입 정의
public enum DeviceType
{
ACS = 0,
AGV1 = 10,
AGV2 = 11,
BUFFER1 = 20,
BUFFER2 = 21,
BUFFER3 = 22,
BUFFER4 = 23,
BUFFER5 = 24,
DOOR = 30,
}
public partial class EEProtocol
{
// 패킷 수신 이벤트 정의
// 데이터 수신 이벤트 정의
public event EventHandler<DataEventArgs> OnDataReceived;
public event EventHandler<MessageEventArgs> OnMessage;
// CRC16 계산을 위한 테이블
private static readonly ushort[] CRC16_TABLE = new ushort[256];
// CRC16 테이블 초기화
public EEProtocol()
{
const ushort polynomial = 0x7979;
for (ushort i = 0; i < CRC16_TABLE.Length; i++)
{
ushort value = 0;
ushort temp = i;
for (byte j = 0; j < 8; j++)
{
if (((value ^ temp) & 0x0001) != 0)
{
value = (ushort)((value >> 1) ^ polynomial);
}
else
{
value >>= 1;
}
temp >>= 1;
}
CRC16_TABLE[i] = value;
}
//// CRC 테이블 출력
//Console.WriteLine("CRC16 테이블 값:");
//for (int i = 0; i < CRC16_TABLE.Length; i++)
//{
// if (i % 8 == 0)
// {
// Console.WriteLine();
// }
// Console.Write($"0x{CRC16_TABLE[i]:X4}, ");
//}
//Console.WriteLine();
}
// CRC16 계산 메서드
public ushort CalculateCRC16(byte[] data)
{
ushort crc = 0xFFFF;
for (int i = 0; i < data.Length; i++)
{
byte index = (byte)(crc ^ data[i]);
crc = (ushort)((crc >> 8) ^ CRC16_TABLE[index]);
}
return crc;
}
// 패킷 생성 메서드
public byte[] CreatePacket(byte id, byte command, byte[] data)
{
var packet = new Packet
{
ID = id,
Command = command,
Data = data ?? new byte[0],
Length = (byte)(1 + 1 + (data?.Length ?? 0)) // ID + Command + Data 길이
};
// 패킷 조립
List<byte> packetData = new List<byte>();
packetData.Add(Packet.STX);
packetData.Add(packet.Length);
packetData.Add(packet.ID);
packetData.Add(packet.Command);
if (packet.Data != null)
packetData.AddRange(packet.Data);
// CRC16 계산
packet.CRC16 = CalculateCRC16(packetData.Skip(1).ToArray()); // STX 제외하고 계산
packetData.AddRange(BitConverter.GetBytes(packet.CRC16));
packetData.Add(Packet.ETX);
return packetData.ToArray();
}
//패킷테스트
public void PacketTest(byte[] rawData)
{
var hexstr = string.Join(" ", rawData.Select(t => t.ToString("X2")));
RaiseMessage( $"TestPacket : {hexstr}");
ParsePacket(rawData);
}
//메세지 발생
public void RaiseMessage(string message, bool isError = false)
{
OnMessage?.Invoke(this, new MessageEventArgs { IsError = isError, Message = message });
}
// 패킷 파싱 메서드
public bool ParsePacket(byte[] rawData)
{
try
{
if (rawData.Length < 7) // 최소 패킷 크기
{
var hexstring = string.Join(" ", rawData.Select(t => t.ToString("X2")));
RaiseMessage($"Too Short Data:{hexstring}");
return false;
}
if (rawData[0] != Packet.STX || rawData[rawData.Length - 1] != Packet.ETX)
{
var hexstring = string.Join(" ", rawData.Select(t => t.ToString("X2")));
RaiseMessage($"STX/ETX Error Data:{hexstring}");
return false;
}
byte length = rawData[1];
if (length + 5 != rawData.Length) // STX + Length + CRC16(2) + ETX = 5
{
var hexstring = string.Join(" ", rawData.Select(t => t.ToString("X2")));
RaiseMessage($"Length Error ({length+5} != {rawData.Length}) Data:{hexstring}");
return false;
}
// CRC16 검증
byte[] dataForCrc = rawData.Skip(1).Take(length + 1).ToArray();
ushort calculatedCrc = CalculateCRC16(dataForCrc);
ushort receivedCrc = BitConverter.ToUInt16(rawData, rawData.Length - 3);
if (receivedCrc != 0xFFFF && calculatedCrc != receivedCrc) //FF 무시
{
RaiseMessage($"CRC Error ID:{rawData[2]:X2},CMD:{rawData[3]:X2}", true);
return false;
}
// 패킷 생성
var packet = new Packet
{
Length = length,
ID = rawData[2],
Command = rawData[3],
Data = rawData.Skip(4).Take(length - 2).ToArray(), // ID와 Command 길이(2) 제외
CRC16 = receivedCrc,
RawData = rawData,
};
// 이벤트 발생
OnDataReceived?.Invoke(this, new DataEventArgs { ReceivedPacket = packet });
return true;
}
catch(Exception ex)
{
RaiseMessage(ex.Message, true);
return false;
}
}
// 데이터 수신 처리 메서드 (시리얼 포트에서 데이터를 받았을 때 호출)
private List<byte> buffer = new List<byte>();
private int ProtocolParseError = 0;
public void ProcessReceivedData(byte[] data)
{
buffer.AddRange(data);
while (buffer.Count > 0)
{
// STX 찾기
int stxIndex = buffer.FindIndex(b => b == Packet.STX);
if (stxIndex == -1)
{
buffer.Clear();
break;
}
// 불필요한 데이터 제거
if (stxIndex > 0)
buffer.RemoveRange(0, stxIndex);
// 패킷 길이 확인을 위한 최소 데이터 확인
if (buffer.Count < 2)
break;
int expectedLength = buffer[1] + 5; // 전체 패킷 길이
if (buffer.Count < expectedLength)
break;
// 패킷 추출 및 처리
byte[] packetData = buffer.Take(expectedLength).ToArray();
buffer.RemoveRange(0, expectedLength);
var parseOK = ParsePacket(packetData);
if(parseOK==false) //분석이 실패되었다면 해당 데이터는 삭제한다.
{
ProtocolParseError += 1;
if (ProtocolParseError > 3) buffer.Clear();
} else ProtocolParseError = 0;
if(buffer.Any())
{
System.Threading.Thread.Sleep(1);
}
}
}
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9365803B-933D-4237-93C7-B502C855A71C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>enigprotocol</RootNamespace>
<AssemblyName>enigprotocol</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands.cs" />
<Compile Include="EEProtocol.cs" />
<Compile Include="EventArgs.cs" />
<Compile Include="Packet.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".gitignore" />
<None Include="ReadMe.MD" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,18 @@
using System;
namespace ENIG
{
public partial class EEProtocol
{
public class MessageEventArgs : EventArgs
{
public string Message { get; set; }
public bool IsError { get; set; }
}
public class DataEventArgs : EventArgs
{
public Packet ReceivedPacket { get; set; }
}
}
}

View File

@@ -0,0 +1,20 @@
namespace ENIG
{
// 패킷 구조체
public class Packet
{
public const byte STX = 0x02;
public const byte ETX = 0x03;
public byte Length { get; set; }
public byte ID { get; set; }
public byte Command { get; set; }
public byte[] Data { get; set; }
public ushort CRC16 { get; set; }
public byte[] RawData { get; set; }
public Packet()
{
Data = new byte[0];
}
}
}

View File

@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
// 이러한 특성 값을 변경하세요.
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyTitle("enigprotocol")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyProduct("enigprotocol")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
[assembly: Guid("19675e19-eb91-493e-88c3-32b3c094b749")]
[assembly: Guid("9365803b-933d-4237-93c7-b502c855a71c")]
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
//

View File

@@ -0,0 +1,236 @@
# ENIG Protocol
ENIG 프로토콜 통신 라이브러리
**Explanation of the README Content:**
1. **Title and Overview:** Clearly states the purpose of the library.
2. **Key Components:** Explains the main building blocks:
* `DeviceType` enum: Lists the device types.
* `Packet` class: Describes the packet structure.
* `EEProtocol` class: Explains its role in packet handling.
3. **Key Features:** Details the core functionalities of the `EEProtocol` class:
* Packet creation.
* Packet parsing.
* Data reception.
* Event-driven nature.
* CRC16 calculation.
4. **Usage:** Provides code examples for:
* Creating a packet.
* Parsing a packet.
* Processing received data.
5. **Error Handling:** Explains how the library handles invalid data and incomplete packets.
6. **Dependencies:** Lists any required frameworks or libraries.
7. **License:** Placeholder for the project's license.
This README provides a comprehensive overview of the `ENIGProtocol` library, making it easy for other developers to understand and use it. I hope this is helpful!
## 개발 환경
- Frameworks : .NET Standard 2.0
- Visual Studio 2022 또는 Visual Studio Code
## 프로젝트 구조
- `EEProtocol.cs`: ENIG 프로토콜 구현
- `EEProtocolTests.cs`: 단위 테스트 코드
- `Sample`: C# Winform 샘플 프로젝트
### Xbee Setting value
- **NARMI 70 : AGV No 70
- **NARMI 70 (LIFT) : P46A6,C17,DH:0,DL:FFFF,MY40
- **NARMI 70 (AGV) : P46A6,C17,DH:0,DL:FFFF,MY41
- **NARMI 77 : AGV No 71
- **NARMI 71 (LIFT) : P46A6,C17,DH:0,DL:FFFF,MY30
- **NARMI 71 (AGV) : P46A6,C17,DH:0,DL:FFFF,MY31
- **충전기04 : P46A6,C17,DH:0,DL:FFFF,MY41
- **충전기71 : P46A6,C17,DH:0,DL:FFFF,MY46
- **ACS : P46A5,C17,DH:0,DL:FFFF,MY10
- **BUFFER : P46A5,C17,DH:0,DL:FFFF,MY60~65
- **AGV1 : P46A5,C17,DH:0,DL:FFFF,MY50
- **AGV2 : P46A5,C17,DH:0,DL:FFFF,MY51
- **DOOR : P46A5,C17,DH:0,DL:FFFF,MY30
## 장비 목록
```
public enum DeviceType : byte
{
ACS = 0,
AGV1 = 10+1,
AGV2 = 10+2,
BUFFER1 = 20+1,
BUFFER2 = 20+2,
BUFFER3 = 20+3,
BUFFER4 = 20+4,
BUFFER5 = 20+5,
DOOR = 30,
}
```
### 기본 패킷 구조
```
[STX][LEN][ID][CMD][DATA][CRC16][ETX]
```
- **STX (Start of Text)**: 0x02
- **LEN (Length)**: 데이터 길이 (1바이트) = {ID+CMD+DATA}
- **ID (Client ID)**: 데이터 길이 (1바이트) : 디바이스식별코드(=DeviceType)
- **CMD (Command)**: 명령어 코드 (1바이트)
- **DATA**: 명령어에 따른 데이터 (가변 길이)
- **CRC16**: 데이터 무결성 검사 (2바이트)
- **ETX (End of Text)**: 0x03
### 통신 방향 (호스트=ACS, 장비=agv,buffer,door)
- H -> E: 호스트에서 장비로 전송
- E -> H: 장비에서 호스트로 전송
### 명령어 목록
1. **ACS (AGV Control System)**
2. **Buffer**
- E -> H | cmd('S'): 상태 (............) BIT & 1BYTE 0:CART1, 1:CART2, 2:BASKET1, 3:BASKET2, 4:OPEN, 5:CLOSE
- H -> E | cmd('L'): Lock
- Target[1] = {DeviceType}
- H -> E | cmd('U'): UnLock
- Target[1] = {DeviceType}
3. **AGV**
- H -> E | Move : cmd(100) : 대상태그까지 이동(자동이동)
- Target[1] = {DeviceType}
- TagID[4] = "0000"
- H -> E | Move : cmd(107) : 대상별칭까지 이동(자동이동)
- Target[1] = {DeviceType}
- AliasName[n] = "....."
- H -> E | Stop : cmd(101) : 멈춤
- H -> E | Reset : cmd(102) : 오류 소거
- H -> E | Charge On: cmd(103) : 충전실행(충전기 이동 후 자동 충전 진행)
- Target[1] = {DeviceType}
- Action[1] : 0=Charge Off, 1=Charge On
- H -> E | MoveManual : cmd(104) : 메뉴얼이동
- Target[1] = {DeviceType}
- Direction[1] : 0=Backward, 1=Forward, 2=TurnLeft, 3=TurnRight
- Speed[1] : 0=Slow, 1=Normal, 2=Fast
- Runtime[1] : 0 second
- H -> E | MarkStop : cmd(105) : 마크센서스톱
- Target[1] = {DeviceType}
- H -> E | Lift Control : cmd(106) : 리프트제어
- Target[1] = {DeviceType}
- Action[1] : 0=STOP, 1=UP, 2=DOWN
- E -> H | Move Complete : cmd(1) : 목적지이동완료 후 전송
- TagID[4] : "0000"
- E -> H | TagID Received : cmd(2) : 태그값 인식시 전송
- TagID[4] : "0000"
- E -> H | Status : cmd(3) - 총 12바이트
- Mode[1] : 0=manual, 1=auto
- RunSt[1] : 0=stop, 1=run, 2=error
MotDirection[1] : 0:Forward, 1:Backward, 0xFF:unknown
- MagDiection[1] : 0=straight, 1=left, 2=right , 0xFF:unknown
- Inposition[1] : 0=off, 1=on : 목적위치에 도달완료 시 설정 이동 이동시 OFF됨
- ChargeSt[1] : 0=off, 1=on
- CartSt[1] : 0=off, 1=on, 2=unknown
- LiftSt[1] : 0=down , 1=up, 2=unknown
- LastTag[4] : "0000" (ASCII 4바이트)
4. **Door**
- H -> E | cmd(1): 출입문 열기
- H -> E | cmd(2): 출입문 닫기
- E -> H | cmd(3): 출입문 상태 (data len=1 : 0=닫힘, 1=열림, 2=바쁨, 3=알수없음, 255=오류)
### CRC16 계산
- CRC16 다항식 사용
- 초기값: 0xFFFF
- 데이터 무결성 검증에 사용
#### CRC-16 테이블 값
```
0x0000, 0x408E, 0x73EF, 0x3361, 0x152D, 0x55A3, 0x66C2, 0x264C,
0x2A5A, 0x6AD4, 0x59B5, 0x193B, 0x3F77, 0x7FF9, 0x4C98, 0x0C16,
0x54B4, 0x143A, 0x275B, 0x67D5, 0x4199, 0x0117, 0x3276, 0x72F8,
0x7EEE, 0x3E60, 0x0D01, 0x4D8F, 0x6BC3, 0x2B4D, 0x182C, 0x58A2,
0x5B9B, 0x1B15, 0x2874, 0x68FA, 0x4EB6, 0x0E38, 0x3D59, 0x7DD7,
0x71C1, 0x314F, 0x022E, 0x42A0, 0x64EC, 0x2462, 0x1703, 0x578D,
0x0F2F, 0x4FA1, 0x7CC0, 0x3C4E, 0x1A02, 0x5A8C, 0x69ED, 0x2963,
0x2575, 0x65FB, 0x569A, 0x1614, 0x3058, 0x70D6, 0x43B7, 0x0339,
0x45C5, 0x054B, 0x362A, 0x76A4, 0x50E8, 0x1066, 0x2307, 0x6389,
0x6F9F, 0x2F11, 0x1C70, 0x5CFE, 0x7AB2, 0x3A3C, 0x095D, 0x49D3,
0x1171, 0x51FF, 0x629E, 0x2210, 0x045C, 0x44D2, 0x77B3, 0x373D,
0x3B2B, 0x7BA5, 0x48C4, 0x084A, 0x2E06, 0x6E88, 0x5DE9, 0x1D67,
0x1E5E, 0x5ED0, 0x6DB1, 0x2D3F, 0x0B73, 0x4BFD, 0x789C, 0x3812,
0x3404, 0x748A, 0x47EB, 0x0765, 0x2129, 0x61A7, 0x52C6, 0x1248,
0x4AEA, 0x0A64, 0x3905, 0x798B, 0x5FC7, 0x1F49, 0x2C28, 0x6CA6,
0x60B0, 0x203E, 0x135F, 0x53D1, 0x759D, 0x3513, 0x0672, 0x46FC,
0x7979, 0x39F7, 0x0A96, 0x4A18, 0x6C54, 0x2CDA, 0x1FBB, 0x5F35,
0x5323, 0x13AD, 0x20CC, 0x6042, 0x460E, 0x0680, 0x35E1, 0x756F,
0x2DCD, 0x6D43, 0x5E22, 0x1EAC, 0x38E0, 0x786E, 0x4B0F, 0x0B81,
0x0797, 0x4719, 0x7478, 0x34F6, 0x12BA, 0x5234, 0x6155, 0x21DB,
0x22E2, 0x626C, 0x510D, 0x1183, 0x37CF, 0x7741, 0x4420, 0x04AE,
0x08B8, 0x4836, 0x7B57, 0x3BD9, 0x1D95, 0x5D1B, 0x6E7A, 0x2EF4,
0x7656, 0x36D8, 0x05B9, 0x4537, 0x637B, 0x23F5, 0x1094, 0x501A,
0x5C0C, 0x1C82, 0x2FE3, 0x6F6D, 0x4921, 0x09AF, 0x3ACE, 0x7A40,
0x3CBC, 0x7C32, 0x4F53, 0x0FDD, 0x2991, 0x691F, 0x5A7E, 0x1AF0,
0x16E6, 0x5668, 0x6509, 0x2587, 0x03CB, 0x4345, 0x7024, 0x30AA,
0x6808, 0x2886, 0x1BE7, 0x5B69, 0x7D25, 0x3DAB, 0x0ECA, 0x4E44,
0x4252, 0x02DC, 0x31BD, 0x7133, 0x577F, 0x17F1, 0x2490, 0x641E,
0x6727, 0x27A9, 0x14C8, 0x5446, 0x720A, 0x3284, 0x01E5, 0x416B,
0x4D7D, 0x0DF3, 0x3E92, 0x7E1C, 0x5850, 0x18DE, 0x2BBF, 0x6B31,
0x3393, 0x731D, 0x407C, 0x00F2, 0x26BE, 0x6630, 0x5551, 0x15DF,
0x19C9, 0x5947, 0x6A26, 0x2AA8, 0x0CE4, 0x4C6A, 0x7F0B, 0x3F85,
```
#### CRC16 계산 테이블 생성 코드
```csharp
const ushort polynomial = 0x7979;
ushort[] CRC16_TABLE = new ushort[256];
for (ushort i = 0; i < CRC16_TABLE.Length; i++)
{
ushort value = 0;
ushort temp = i;
for (byte j = 0; j < 8; j++)
{
if (((value ^ temp) & 0x0001) != 0)
{
value = (ushort)((value >> 1) ^ polynomial);
}
else
{
value >>= 1;
}
temp >>= 1;
}
CRC16_TABLE[i] = value;
}
```
#### CRC16 계산 예시
```csharp
ushort CalculateCRC16(byte[] data)
{
ushort crc = 0xFFFF;
for (int i = 0; i < data.Length; i++)
{
byte index = (byte)(crc ^ data[i]);
crc = (ushort)((crc >> 8) ^ CRC16_TABLE[index]);
}
return crc;
}
```
## 라이센스

Some files were not shown because too many files have changed in this diff Show More