185 lines
5.9 KiB
C#
185 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using AGVNavigationCore.Utils;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace AGVNavigationCore.Models
|
|
{
|
|
/// <summary>
|
|
/// 맵 노드 정보를 관리하는 클래스 (주행 경로용 노드)
|
|
/// </summary>
|
|
public class MapNode : NodeBase
|
|
{
|
|
|
|
|
|
[Category("라벨 설정")]
|
|
[Description("표시할 텍스트입니다.")]
|
|
public string Text { get; set; } = "";
|
|
|
|
public StationType 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;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
[Category("노드 설정")]
|
|
[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)]
|
|
public List<string> ConnectedNodes { get; set; } = new List<string>();
|
|
|
|
[JsonIgnore]
|
|
[Browsable(false)]
|
|
public List<MapNode> ConnectedMapNodes { get; set; } = new List<MapNode>();
|
|
|
|
[Category("주행 설정")]
|
|
[Description("제자리 회전(좌) 가능 여부입니다.")]
|
|
public bool CanTurnLeft { get; set; } = true;
|
|
|
|
[Category("주행 설정")]
|
|
[Description("제자리 회전(우) 가능 여부입니다.")]
|
|
public bool CanTurnRight { get; set; } = true;
|
|
|
|
[Category("주행 설정")]
|
|
[Description("교차로 주행 가능 여부입니다.")]
|
|
public bool DisableCross
|
|
{
|
|
get
|
|
{
|
|
if (Type != NodeType.Normal) return true;
|
|
return _disablecross;
|
|
}
|
|
set { _disablecross = value; }
|
|
}
|
|
private bool _disablecross = false;
|
|
|
|
[Category("주행 설정")]
|
|
[Description("노드 통과 시 제한 속도입니다.")]
|
|
public SpeedLevel SpeedLimit { get; set; } = SpeedLevel.M;
|
|
|
|
[Category("노드 설정")]
|
|
[Description("장비 ID 또는 별칭입니다.")]
|
|
public string AliasName { get; set; } = string.Empty;
|
|
|
|
[Category("기본 정보")]
|
|
[Description("노드 사용 여부입니다.")]
|
|
public bool IsActive { get; set; } = true;
|
|
|
|
[Category("RFID 정보")]
|
|
[Description("물리적 RFID 태그 ID입니다.")]
|
|
public UInt16 RfidId { get; set; } = 0;
|
|
|
|
|
|
[Category("노드 텍스트"), DisplayName("TextColor")]
|
|
[Description("텍스트 색상입니다.")]
|
|
public Color NodeTextForeColor { get; set; } = Color.Black;
|
|
|
|
private float _textFontSize = 7.0f;
|
|
[Category("노드 텍스트"), DisplayName("TextSize")]
|
|
[Description("일반 노드 텍스트의 크기입니다.")]
|
|
public float NodeTextFontSize
|
|
{
|
|
get => _textFontSize;
|
|
set => _textFontSize = value > 0 ? value : 7.0f;
|
|
}
|
|
|
|
public MapNode() : base()
|
|
{
|
|
Type = NodeType.Normal;
|
|
}
|
|
|
|
public MapNode(string nodeId, Point position, StationType type) : base(nodeId, position)
|
|
{
|
|
Type = NodeType.Normal;
|
|
}
|
|
[Category("기본 정보")]
|
|
[JsonIgnore]
|
|
[ReadOnly(true), Browsable(false)]
|
|
public bool isDockingNode
|
|
{
|
|
get
|
|
{
|
|
if (StationType == StationType.Charger1 || StationType == StationType.Charger2 || StationType == StationType.Buffer ||
|
|
StationType == StationType.Clearner || StationType == StationType.Loader ||
|
|
StationType == StationType.UnLoader) return true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void AddConnection(string nodeId)
|
|
{
|
|
if (!ConnectedNodes.Contains(nodeId))
|
|
{
|
|
ConnectedNodes.Add(nodeId);
|
|
ModifiedDate = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
public void RemoveConnection(string nodeId)
|
|
{
|
|
if (ConnectedNodes.Remove(nodeId))
|
|
{
|
|
ModifiedDate = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
public void SetChargingStation(string stationId)
|
|
{
|
|
//StationType = StationType.Charger;
|
|
//Id = stationId;
|
|
//DockDirection = DockingDirection.Forward;
|
|
//ModifiedDate = DateTime.Now;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"RFID:{RfidId}(NODE:{Id}): AS:{AliasName} ({Type}) at ({Position.X}, {Position.Y})";
|
|
}
|
|
|
|
/// <summary>
|
|
/// RFID(*ID)
|
|
/// </summary>
|
|
public string ID2
|
|
{
|
|
get
|
|
{
|
|
if (HasRfid()) return $"{this.RfidId:0000}(*{this.Id})";
|
|
else return $"(*{this.Id})";
|
|
}
|
|
}
|
|
|
|
public bool IsNavigationNode()
|
|
{
|
|
// 이제 MapNode는 항상 내비게이션 노드임 (Label, Image 분리됨)
|
|
// 하지만 기존 로직 호환성을 위해 Active 체크만 유지
|
|
return IsActive;
|
|
}
|
|
|
|
public bool HasRfid()
|
|
{
|
|
return RfidId > 0;
|
|
}
|
|
}
|
|
} |