최종우치에. 이전노드정보와 다음 시작 노드 정보를 모두 추가함.
최초 실행시 선택하는 위치 다이얼로그 제거 후 바로 자동 로딩하도록 함
This commit is contained in:
@@ -245,6 +245,7 @@
|
|||||||
<Compile Include="Dialog\fVolume.Designer.cs">
|
<Compile Include="Dialog\fVolume.Designer.cs">
|
||||||
<DependentUpon>fVolume.cs</DependentUpon>
|
<DependentUpon>fVolume.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Class\LastPositionData.cs" />
|
||||||
<Compile Include="MessageWindow\fMessageWindow.cs">
|
<Compile Include="MessageWindow\fMessageWindow.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
27
HMI/Project/Class/LastPositionData.cs
Normal file
27
HMI/Project/Class/LastPositionData.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using AGVNavigationCore.Models;
|
||||||
|
|
||||||
|
namespace Project
|
||||||
|
{
|
||||||
|
public class LastPositionData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 현재노드id
|
||||||
|
/// </summary>
|
||||||
|
public string NodeId { get; set; }
|
||||||
|
public AgvDirection Direction { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public AGVTurn Turn { get; set; }
|
||||||
|
public DateTime SaveTime { get; set; }
|
||||||
|
public string PrevNode { get; set; }
|
||||||
|
public AgvDirection PrevDirection { get; set; }
|
||||||
|
public string StartNode { get; set; }
|
||||||
|
public string TargetNode { get; set; }
|
||||||
|
|
||||||
|
public arDev.NarumiTurnInfo AGV_Turn { get; set; }
|
||||||
|
public char AGV_Motor { get; set; }
|
||||||
|
public char AGV_Speed { get; set; }
|
||||||
|
public string AGV_TagString { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,13 +25,6 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace Project
|
namespace Project
|
||||||
{
|
{
|
||||||
public class LastPositionData
|
|
||||||
{
|
|
||||||
public string NodeId { get; set; }
|
|
||||||
public AgvDirection Direction { get; set; }
|
|
||||||
public AGVTurn Turn { get; set; }
|
|
||||||
public DateTime SaveTime { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PUB
|
public static class PUB
|
||||||
{
|
{
|
||||||
@@ -121,7 +114,7 @@ namespace Project
|
|||||||
/// <param name="m"></param>
|
/// <param name="m"></param>
|
||||||
/// <param name="force"></param>
|
/// <param name="force"></param>
|
||||||
/// <param name="addlog">로그에도 출력 합니다</param>
|
/// <param name="addlog">로그에도 출력 합니다</param>
|
||||||
public static void Speak(string m, Boolean force = false, bool addlog = true,string logcate="")
|
public static void Speak(string m, Boolean force = false, bool addlog = true, string logcate = "")
|
||||||
{
|
{
|
||||||
if (force == false && PUB.setting.Enable_Speak == false)
|
if (force == false && PUB.setting.Enable_Speak == false)
|
||||||
{
|
{
|
||||||
@@ -666,7 +659,7 @@ namespace Project
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (_virtualAGV == null) return;
|
if (_virtualAGV == null) return;
|
||||||
if(_virtualAGV.CurrentDirection != direction)
|
if (_virtualAGV.CurrentDirection != direction)
|
||||||
{
|
{
|
||||||
PUB.log.Add($"[PUB] AGV Direction Change {_virtualAGV.CurrentDirection}->{direction}");
|
PUB.log.Add($"[PUB] AGV Direction Change {_virtualAGV.CurrentDirection}->{direction}");
|
||||||
_virtualAGV.CurrentDirection = direction;
|
_virtualAGV.CurrentDirection = direction;
|
||||||
@@ -682,7 +675,7 @@ namespace Project
|
|||||||
{
|
{
|
||||||
if (_virtualAGV == null) return;
|
if (_virtualAGV == null) return;
|
||||||
|
|
||||||
if(_virtualAGV.CurrentState != state)
|
if (_virtualAGV.CurrentState != state)
|
||||||
{
|
{
|
||||||
PUB.log.Add($"[PUB] AGV State Change {_virtualAGV.CurrentState}->{state}");
|
PUB.log.Add($"[PUB] AGV State Change {_virtualAGV.CurrentState}->{state}");
|
||||||
_virtualAGV.CurrentState = state;
|
_virtualAGV.CurrentState = state;
|
||||||
@@ -723,6 +716,7 @@ namespace Project
|
|||||||
{
|
{
|
||||||
if (_virtualAGV == null || _virtualAGV.CurrentNode == null) return;
|
if (_virtualAGV == null || _virtualAGV.CurrentNode == null) return;
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = new LastPositionData
|
var data = new LastPositionData
|
||||||
@@ -730,7 +724,15 @@ namespace Project
|
|||||||
NodeId = _virtualAGV.CurrentNode.Id,
|
NodeId = _virtualAGV.CurrentNode.Id,
|
||||||
Direction = _virtualAGV.CurrentDirection,
|
Direction = _virtualAGV.CurrentDirection,
|
||||||
Turn = _virtualAGV.Turn,
|
Turn = _virtualAGV.Turn,
|
||||||
SaveTime = DateTime.Now
|
SaveTime = DateTime.Now,
|
||||||
|
AGV_Motor = PUB.AGV.data.Direction,
|
||||||
|
AGV_Speed = PUB.AGV.data.Speed,
|
||||||
|
AGV_TagString = PUB.AGV.data.TagString,
|
||||||
|
PrevNode = _virtualAGV.PrevNode?.Id ?? string.Empty,
|
||||||
|
PrevDirection = _virtualAGV.PrevDirection,
|
||||||
|
StartNode = _virtualAGV.StartNode?.Id ?? string.Empty,
|
||||||
|
TargetNode = _virtualAGV.TargetNode?.Id ?? string.Empty,
|
||||||
|
AGV_Turn = PUB.AGV.TurnInformation,
|
||||||
};
|
};
|
||||||
|
|
||||||
var fi = new System.IO.FileInfo(LastPosFilePath);
|
var fi = new System.IO.FileInfo(LastPosFilePath);
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ namespace Project
|
|||||||
{
|
{
|
||||||
//절반이상 경로가 짧을때에는 재계산을 하게한다
|
//절반이상 경로가 짧을때에는 재계산을 하게한다
|
||||||
var halfcnt = (int)(PUB._virtualAGV.CurrentPath.DetailedPath.Count / 2.0);
|
var halfcnt = (int)(PUB._virtualAGV.CurrentPath.DetailedPath.Count / 2.0);
|
||||||
if (PathResult2.DetailedPath.Count < halfcnt)
|
if (PathResult2.DetailedPath.Count > 2 && PathResult2.DetailedPath.Count < halfcnt)
|
||||||
{
|
{
|
||||||
var msg = $"단축경로가 확인되었습니다. 경로를 삭제 합니다";
|
var msg = $"단축경로가 확인되었습니다. 경로를 삭제 합니다";
|
||||||
PUB.log.AddE(msg);
|
PUB.log.AddE(msg);
|
||||||
@@ -234,12 +234,23 @@ namespace Project
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Moveforce = false;
|
||||||
|
if(nextAction.Motor == MotorCommand.Stop && nextAction.Reason == eAGVCommandReason.MarkStop)
|
||||||
|
{
|
||||||
|
//마크스탑을 해야하는데 움직이지 않는다면 움직이도록 해야한다
|
||||||
|
if(PUB.AGV.system1.agv_run==false)
|
||||||
|
{
|
||||||
|
PUB.log.Add("마크스탑을 해야하는데 중지상태라서 강제 이동하도록 합니다");
|
||||||
|
Moveforce = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//모터에서 정지를 요청했다
|
//모터에서 정지를 요청했다
|
||||||
if (nextAction.Motor == AGVNavigationCore.Models.MotorCommand.Stop)
|
if (Moveforce == false && nextAction.Motor == AGVNavigationCore.Models.MotorCommand.Stop)
|
||||||
{
|
{
|
||||||
if (PUB.AGV.system1.agv_run)
|
if (PUB.AGV.system1.agv_run)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 완료(Complete) 상태라면 MarkStop 전송
|
// 완료(Complete) 상태라면 MarkStop 전송
|
||||||
if (nextAction.Reason == AGVNavigationCore.Models.eAGVCommandReason.MarkStop)
|
if (nextAction.Reason == AGVNavigationCore.Models.eAGVCommandReason.MarkStop)
|
||||||
{
|
{
|
||||||
@@ -277,22 +288,19 @@ namespace Project
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//이동중이라면 멈추는 명령을 전송하거나, 마크스탑을 진행해야하낟.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextAction.Reason == eAGVCommandReason.Complete)
|
||||||
|
{
|
||||||
// 목적지 도착 여부 확인
|
// 목적지 도착 여부 확인
|
||||||
// .. (생략) ..
|
if (PUB.AGV.signal1.mark_sensor == false)
|
||||||
if (PUB._virtualAGV.IsPositionConfirmed)
|
|
||||||
{
|
{
|
||||||
if (PUB.AGV.system1.agv_run == false)
|
|
||||||
{
|
PUB.log.AddI($"목표도착되었으나 마크센서가 감지되지 않아 완료처리 하지않습니다");
|
||||||
//마크센서확인
|
|
||||||
if(PUB.AGV.signal1.mark_sensor==false)
|
|
||||||
{
|
|
||||||
PUB.log.AddI($"목표도착되었으나 마크센서가 감지되지 않아 경로를 삭제 합니다");
|
|
||||||
PUB._virtualAGV.SetPath(null);
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 경로가 존재한다면...
|
// 경로가 존재한다면...
|
||||||
@@ -311,8 +319,8 @@ namespace Project
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// [DEBUG] 도착했으나 조건 불일치
|
// [DEBUG] 도착했으나 조건 불일치, 그러면.. predict 가 stop을 반환하면 안된다.
|
||||||
// PUB.log.Add($"[DEBUG] Arrived but condition mismatch. CurNode:{PUB._virtualAGV.CurrentNode.Id}, Target:{lastInfo.NodeId}, CurDir:{PUB._virtualAGV.CurrentDirection}, TargetDir:{lastInfo.MotorDirection}");
|
PUB.log.Add($"[DEBUG] Arrived but condition mismatch. CurNode:{PUB._virtualAGV.CurrentNode.Id}, Target:{lastInfo.NodeId}, CurDir:{PUB._virtualAGV.CurrentDirection}, TargetDir:{lastInfo.MotorDirection}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -326,7 +334,8 @@ namespace Project
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,14 @@ namespace Project
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//s/w턴이 걸려있다면 이동 불가로한다.(버퍼 작업중이다)
|
||||||
|
if(PUB._virtualAGV.Turn != AGVTurn.None)
|
||||||
|
{
|
||||||
|
SetRunStepError(ENIGProtocol.AGVErrorCode.BUFFER_NOT_COMPLETE, $"[{logPrefix}-Goto] 버퍼작업이 완료되지 않았습니다");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//목적지
|
//목적지
|
||||||
PUB._virtualAGV.TargetNode = targetNode;
|
PUB._virtualAGV.TargetNode = targetNode;
|
||||||
if (targetNode == null)
|
if (targetNode == null)
|
||||||
@@ -233,6 +241,7 @@ namespace Project
|
|||||||
PUB.sm.ResetRunStepSeq();
|
PUB.sm.ResetRunStepSeq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUB.SaveLastPosition();
|
||||||
|
|
||||||
//Move to
|
//Move to
|
||||||
PUB.log.Add($"[{logPrefix}-{cmd}] {startNode.RfidId} -> {targetNode.RfidId}");
|
PUB.log.Add($"[{logPrefix}-{cmd}] {startNode.RfidId} -> {targetNode.RfidId}");
|
||||||
|
|||||||
@@ -310,24 +310,70 @@ namespace Project
|
|||||||
}
|
}
|
||||||
PUB.log.Add($"맵 파일 로드 완료: {filePath.Name}, 노드 수: {result.Nodes.Count}");
|
PUB.log.Add($"맵 파일 로드 완료: {filePath.Name}, 노드 수: {result.Nodes.Count}");
|
||||||
|
|
||||||
// 🔥 초기 위치 설정 및 확인 화면 표시
|
//마지막위치복원
|
||||||
this.BeginInvoke(new Action(() =>
|
// 마지막 위치 로드
|
||||||
|
var lastPos = PUB.LoadLastPosition();
|
||||||
|
if (lastPos != null)
|
||||||
{
|
{
|
||||||
using (var f = new Dialog.fSetCurrentPosition())
|
var sb = new System.Text.StringBuilder();
|
||||||
|
var curNode = PUB.FindByNodeID(lastPos.NodeId);
|
||||||
|
var prevNode = PUB.FindByNodeID(lastPos.PrevNode);
|
||||||
|
var targNode = PUB.FindByNodeID(lastPos.TargetNode);
|
||||||
|
var staNode = PUB.FindByNodeID(lastPos.StartNode);
|
||||||
|
if(prevNode != null)
|
||||||
{
|
{
|
||||||
if (f.ShowDialog() == DialogResult.OK)
|
PUB._virtualAGV.SetPosition(prevNode, lastPos.PrevDirection);
|
||||||
{
|
PUB._mapCanvas.SetAGVPosition(PUB.setting.MCID, prevNode, lastPos.PrevDirection);
|
||||||
if (f.SelectedNode != null)
|
sb.AppendLine($"이전: {prevNode.ID2}, {lastPos.PrevDirection}");
|
||||||
{
|
|
||||||
PUB._virtualAGV.Turn = f.SelectedTurn;
|
|
||||||
PUB._virtualAGV.SetPosition(f.SelectedNode, f.SelectedDirection);
|
|
||||||
PUB._mapCanvas.SetAGVPosition(PUB.setting.MCID, f.SelectedNode, f.SelectedDirection);
|
|
||||||
PUB.SaveLastPosition();
|
|
||||||
PUB.log.Add($"[초기위치] 설정 완료: {f.SelectedNode.Id}, {f.SelectedDirection}, Turn:{f.SelectedTurn}");
|
|
||||||
}
|
}
|
||||||
|
if (curNode != null)
|
||||||
|
{
|
||||||
|
PUB._virtualAGV.SetPosition(curNode, lastPos.Direction);
|
||||||
|
PUB._mapCanvas.SetAGVPosition(PUB.setting.MCID, curNode, lastPos.Direction);
|
||||||
|
sb.AppendLine($"현재: {curNode.ID2}, {lastPos.Direction}");
|
||||||
}
|
}
|
||||||
|
if (staNode != null)
|
||||||
|
{
|
||||||
|
PUB._virtualAGV.StartNode = staNode;
|
||||||
|
sb.AppendLine($"시직:{staNode.ID2}");
|
||||||
}
|
}
|
||||||
}));
|
if (targNode != null)
|
||||||
|
{
|
||||||
|
PUB._virtualAGV.TargetNode = targNode;
|
||||||
|
sb.AppendLine($"대상:{targNode.ID2}");
|
||||||
|
}
|
||||||
|
|
||||||
|
PUB._virtualAGV.Turn = lastPos.Turn;
|
||||||
|
sb.AppendLine($"S/W회전:{lastPos.Turn}");
|
||||||
|
|
||||||
|
if(lastPos.AGV_Turn != null)
|
||||||
|
{
|
||||||
|
PUB.AGV.TurnInformation = lastPos.AGV_Turn;
|
||||||
|
sb.AppendLine($"H/W회전:{lastPos.AGV_Turn}");
|
||||||
|
}
|
||||||
|
|
||||||
|
PUB.log.Add($"위치복원\n{sb}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// 🔥 초기 위치 설정 및 확인 화면 표시
|
||||||
|
//this.BeginInvoke(new Action(() =>
|
||||||
|
//{
|
||||||
|
// using (var f = new Dialog.fSetCurrentPosition())
|
||||||
|
// {
|
||||||
|
// if (f.ShowDialog() == DialogResult.OK)
|
||||||
|
// {
|
||||||
|
// if (f.SelectedNode != null)
|
||||||
|
// {
|
||||||
|
// PUB._virtualAGV.Turn = f.SelectedTurn;
|
||||||
|
// PUB._virtualAGV.SetPosition(f.SelectedNode, f.SelectedDirection);
|
||||||
|
// PUB._mapCanvas.SetAGVPosition(PUB.setting.MCID, f.SelectedNode, f.SelectedDirection);
|
||||||
|
// PUB.SaveLastPosition();
|
||||||
|
// PUB.log.Add($"[초기위치] 설정 완료: {f.SelectedNode.Id}, {f.SelectedDirection}, Turn:{f.SelectedTurn}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user