..
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AGVControl.Models
|
||||
{
|
||||
@@ -13,23 +14,23 @@ namespace AGVControl.Models
|
||||
Stop = 2
|
||||
}
|
||||
|
||||
public class CRFIDData
|
||||
{
|
||||
public UInt16 rfid { get; set; }
|
||||
public Point Position { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return $"RFID:{rfid},P:{Position.X},{Position.Y}";
|
||||
}
|
||||
}
|
||||
//public class CRFIDData
|
||||
//{
|
||||
// public UInt16 Value { get; set; }
|
||||
// public Point Location { get; set; }
|
||||
// public override string ToString()
|
||||
// {
|
||||
// return $"RFID:{Value},P:{Location.X},{Location.Y}";
|
||||
// }
|
||||
//}
|
||||
|
||||
public class movehistorydata : CRFIDData
|
||||
public class movehistorydata : RFIDPoint
|
||||
{
|
||||
public Direction direction { get; set; }
|
||||
public Direction Direction { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"RFID:{rfid},DIR:{direction},P:{Position.X},{Position.Y}";
|
||||
return $"RFID:{Value},DIR:{Direction},P:{Location.X},{Location.Y}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,24 +79,32 @@ namespace AGVControl.Models
|
||||
/// </summary>
|
||||
public Direction TargetDirection { get; set; } = Direction.Stop;
|
||||
public bool IsMoving { get; set; }
|
||||
public bool IsMarkCheck { get; set; }
|
||||
public bool IsTargetDirectionMatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 메인경로
|
||||
/// 경로검색으로 입력된 경로
|
||||
/// </summary>
|
||||
public List<RFIDPoint> CurrentPath { get; set; } = new List<RFIDPoint>();
|
||||
public List<RFIDPoint> MainPath { get; set; } = new List<RFIDPoint>();
|
||||
|
||||
/// <summary>
|
||||
/// 메인경로외에 거쳐가는 중간 경로
|
||||
/// </summary>
|
||||
public List<RFIDPoint> SubPath { get; set; }
|
||||
|
||||
|
||||
public List<Point> PlannedPath { get; set; }
|
||||
public List<string> PathRFIDs { get; set; }
|
||||
|
||||
// 이동 경로 기록을 위한 새로운 속성들
|
||||
public List<movehistorydata> MovementHistory { get; } = new List<movehistorydata>();
|
||||
|
||||
public const int HISTORY_SIZE = 4; // 최근 4개 위치 기록
|
||||
public const int HISTORY_SIZE = 10; // 최근 4개 위치 기록
|
||||
|
||||
public AGV()
|
||||
{
|
||||
CurrentPath = new List<RFIDPoint>();
|
||||
PlannedPath = new List<Point>();
|
||||
MainPath = new List<RFIDPoint>();
|
||||
SubPath = new List<RFIDPoint>();
|
||||
PathRFIDs = new List<string>();
|
||||
|
||||
CurrentRFID = new RFIDPoint();
|
||||
@@ -110,10 +119,10 @@ namespace AGVControl.Models
|
||||
public void AddToMovementHistory(UInt16 rfidValue, Point position, Direction direction)
|
||||
{
|
||||
// 중복 RFID가 연속으로 들어오는 경우 무시
|
||||
if (MovementHistory.Count > 0 && MovementHistory.Last().rfid == rfidValue)
|
||||
if (MovementHistory.Count > 0 && MovementHistory.Last().Value == rfidValue)
|
||||
return;
|
||||
|
||||
MovementHistory.Add(new movehistorydata { rfid = rfidValue, direction = direction, Position = position });
|
||||
MovementHistory.Add(new movehistorydata { Value = rfidValue, Direction = direction, Location = position });
|
||||
|
||||
// 기록 크기 제한
|
||||
if (MovementHistory.Count > HISTORY_SIZE)
|
||||
@@ -122,7 +131,7 @@ namespace AGVControl.Models
|
||||
}
|
||||
|
||||
//최초방향과 마지막 방향이 일치하지 않으면 그 이전의 데이터는 삭제한다.
|
||||
if (MovementHistory.Count > 2 && MovementHistory.First().direction != MovementHistory.Last().direction)
|
||||
if (MovementHistory.Count > 2 && MovementHistory.First().Direction != MovementHistory.Last().Direction)
|
||||
{
|
||||
var lastTwo = MovementHistory.Skip(MovementHistory.Count - 2).Take(2).ToArray(); // [9, 10]
|
||||
MovementHistory.Clear();
|
||||
@@ -138,14 +147,14 @@ namespace AGVControl.Models
|
||||
|
||||
// 이전 RFID에서 현재 RFID로의 연결 확인
|
||||
var connection = connections.FirstOrDefault(c =>
|
||||
(c.StartRFID == previousRFID && c.EndRFID == currentRFID) ||
|
||||
(c.IsBidirectional && c.StartRFID == currentRFID && c.EndRFID == previousRFID));
|
||||
(c.P1.Value == previousRFID && c.P2.Value == currentRFID) ||
|
||||
(c.P1.Value == currentRFID && c.P2.Value == previousRFID));
|
||||
|
||||
if (connection == null)
|
||||
return null; // 연결되지 않은 경로
|
||||
|
||||
// 연결 방향에 따라 실제 이동 방향 결정
|
||||
if (connection.StartRFID == previousRFID && connection.EndRFID == currentRFID)
|
||||
if (connection.P1.Value == previousRFID && connection.P2.Value == currentRFID)
|
||||
{
|
||||
return Direction.Forward; // Start -> End 방향으로 이동
|
||||
}
|
||||
@@ -169,7 +178,7 @@ namespace AGVControl.Models
|
||||
var previousRFID = recentRFIDs[0];
|
||||
var currentRFID = recentRFIDs[1];
|
||||
|
||||
var actualDirection = CalculateActualDirectionByConnection(currentRFID.rfid, previousRFID.rfid, connections);
|
||||
var actualDirection = CalculateActualDirectionByConnection(currentRFID.Value, previousRFID.Value, connections);
|
||||
if (!actualDirection.HasValue)
|
||||
return true; // 연결 정보로 방향 판단 불가
|
||||
|
||||
@@ -201,11 +210,11 @@ namespace AGVControl.Models
|
||||
var currentRFID = recentRFIDs[1];
|
||||
|
||||
// RFID 값의 증가/감소로 방향 판단
|
||||
if (currentRFID.rfid > prevRFID.rfid)
|
||||
if (currentRFID.Value > prevRFID.Value)
|
||||
{
|
||||
return Direction.Forward; // RFID 값이 증가하면 전진
|
||||
}
|
||||
else if (currentRFID.rfid < prevRFID.rfid)
|
||||
else if (currentRFID.Value < prevRFID.Value)
|
||||
{
|
||||
return Direction.Backward; // RFID 값이 감소하면 후진
|
||||
}
|
||||
|
||||
14
Cs_HMI/SubProject/AGVControl/Models/AGVActionPrediction.cs
Normal file
14
Cs_HMI/SubProject/AGVControl/Models/AGVActionPrediction.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using AGVControl.Models;
|
||||
|
||||
namespace AGVControl
|
||||
{
|
||||
public class AGVActionPrediction
|
||||
{
|
||||
public Direction Direction { get; set; }
|
||||
public uint? NextRFID { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public AGVActionReasonCode ReasonCode { get; set; }
|
||||
public AGVMoveState MoveState { get; set; } // RUN 또는 STOP
|
||||
}
|
||||
|
||||
}
|
||||
23
Cs_HMI/SubProject/AGVControl/Models/PathResult.cs
Normal file
23
Cs_HMI/SubProject/AGVControl/Models/PathResult.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using AGVControl.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AGVControl
|
||||
{
|
||||
public class PathResult
|
||||
|
||||
{
|
||||
public bool Success
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path != null && Path.Any();
|
||||
}
|
||||
}
|
||||
public string Message { get; set; }
|
||||
public List<RFIDPoint> Path { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
33
Cs_HMI/SubProject/AGVControl/Models/RFIDConnection.cs
Normal file
33
Cs_HMI/SubProject/AGVControl/Models/RFIDConnection.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using AGVControl.Models;
|
||||
|
||||
namespace AGVControl
|
||||
{
|
||||
public class RFIDConnection
|
||||
{
|
||||
public RFIDPoint P1 { get; set; }
|
||||
public RFIDPoint P2 { get; set; }
|
||||
public bool DisableP1_to_P2 { get; set; }
|
||||
public bool DisableP2_to_P1 { get; set; }
|
||||
public float Distance { get; set; }
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is RFIDConnection other)
|
||||
{
|
||||
return (P1 == other.P1 && P2 == other.P2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return P1.GetHashCode() ^ P2.GetHashCode();
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
//연결정보를 확인
|
||||
return $"{P1.Value} ↔ {P2.Value},P1-2:{(DisableP1_to_P2 ? "X" : "O")},P2-1:{(DisableP2_to_P1 ? "X" : "O")}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ namespace AGVControl.Models
|
||||
public Direction? FixedDirection { get; set; } // 고정 방향(없으면 null)
|
||||
public bool IsTerminal { get; set; } // 종단 여부
|
||||
public RectangleF Bounds { get; set; }
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
this.Location = Point.Empty;
|
||||
@@ -38,5 +37,10 @@ namespace AGVControl.Models
|
||||
IsTerminal = false; // 기본값은 종단 아님
|
||||
Clear();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[RFIDPoint] {Value},P:{Location.X},{Location.Y}";
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Cs_HMI/SubProject/AGVControl/Models/enumStruct.cs
Normal file
30
Cs_HMI/SubProject/AGVControl/Models/enumStruct.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AGVControl
|
||||
{
|
||||
|
||||
public enum AGVMoveState
|
||||
{
|
||||
Stop = 0,
|
||||
Run
|
||||
}
|
||||
|
||||
public enum AGVActionReasonCode
|
||||
{
|
||||
Unknown = 0,
|
||||
NoPosition, // 위치 미확정(처음 기동)
|
||||
NoPath, // 경로 없음 또는 현재 위치 미확정
|
||||
NotOnPath, // 현재 위치가 경로에 없음
|
||||
Arrived, // 경로의 마지막 지점(목적지 도달)
|
||||
Normal, // 정상(다음 RFID 있음)
|
||||
NeedTurn,
|
||||
NoTurnPoint,
|
||||
PathCalcError,
|
||||
NoDirection,
|
||||
MoveForTurn,
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\AGVActionPrediction.cs" />
|
||||
<Compile Include="BatteryLevelGauge.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -57,16 +58,20 @@
|
||||
<Compile Include="GuideSensor.Designer.cs">
|
||||
<DependentUpon>GuideSensor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MapControl.cs" />
|
||||
<Compile Include="MapControl.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MapControl.Designer.cs">
|
||||
<DependentUpon>MapControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\AGV.cs" />
|
||||
<Compile Include="Models\CustomLine.cs" />
|
||||
<Compile Include="Models\enumStruct.cs" />
|
||||
<Compile Include="Models\MagnetLine.cs" />
|
||||
<Compile Include="Models\MapData.cs" />
|
||||
<Compile Include="Models\MapElements.cs" />
|
||||
<Compile Include="Models\MapText.cs" />
|
||||
<Compile Include="Models\PathResult.cs" />
|
||||
<Compile Include="Models\RFIDLine.cs" />
|
||||
<Compile Include="Models\RFIDPoint.cs" />
|
||||
<Compile Include="Models\ToolBarItem.cs" />
|
||||
@@ -82,6 +87,7 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\RFIDConnection.cs" />
|
||||
<Compile Include="RoundButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -105,6 +111,10 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommData\CommData.csproj">
|
||||
<Project>{14e8c9a5-013e-49ba-b435-efefc77dd623}</Project>
|
||||
<Name>CommData</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CommUtil\arCommUtil.csproj">
|
||||
<Project>{14e8c9a5-013e-49ba-b435-ffffff7dd623}</Project>
|
||||
<Name>arCommUtil</Name>
|
||||
|
||||
Reference in New Issue
Block a user