..
This commit is contained in:
@@ -39,178 +39,189 @@ namespace Project
|
||||
bool _charging = false;
|
||||
private void AGV_DataReceive(object sender, arDev.Narumi.DataEventArgs e)
|
||||
{
|
||||
if (PUB.mapctl != null)
|
||||
PUB.mapctl.PredictNextAction();
|
||||
|
||||
switch (e.DataType)
|
||||
try
|
||||
{
|
||||
case arDev.Narumi.DataType.STS:
|
||||
{
|
||||
//마크센서 확인
|
||||
var chg_mark1 = PUB.AGV.signal.GetChanged(arDev.Narumi.Signal.eflag.mark_sensor_1);
|
||||
var chg_mark2 = PUB.AGV.signal.GetChanged(arDev.Narumi.Signal.eflag.mark_sensor_1);
|
||||
var chg_run = PUB.AGV.system1.GetChanged(arDev.Narumi.SystemFlag1.eflag.agv_run);
|
||||
var chg_stop = PUB.AGV.system1.GetChanged(arDev.Narumi.SystemFlag1.eflag.agv_stop);
|
||||
//if (chg_run && PUB.AGV.system1.agv_run) PUB.Speak("이동을 시작 합니다");
|
||||
VAR.BOOL[eVarBool.AGVDIR_UP] = PUB.AGV.data.Direction == 'B';
|
||||
// PUB.AGV.signal.mark_sensor = PUB.AGV.signal.mark_sensor;
|
||||
VAR.BOOL[eVarBool.AGV_ERROR] = PUB.AGV.error.Value > 0;
|
||||
VAR.BOOL[eVarBool.EMERGENCY] = PUB.AGV.error.Emergency;
|
||||
|
||||
//모터방향 입력
|
||||
if (PUB.AGV.data.Direction == 'B')
|
||||
PUB.mapctl.agv.CurrentMOTDirection = AGVControl.Models.Direction.Backward;
|
||||
else
|
||||
PUB.mapctl.agv.CurrentMOTDirection = AGVControl.Models.Direction.Forward;
|
||||
|
||||
if (PUB.AGV.signal.mark_sensor == false)
|
||||
if (PUB.mapctl != null)
|
||||
PUB.mapctl.PredictNextAction();
|
||||
|
||||
switch (e.DataType)
|
||||
{
|
||||
case arDev.Narumi.DataType.STS:
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == false)
|
||||
//마크센서 확인
|
||||
var chg_mark1 = PUB.AGV.signal.GetChanged(arDev.Narumi.Signal.eflag.mark_sensor_1);
|
||||
var chg_mark2 = PUB.AGV.signal.GetChanged(arDev.Narumi.Signal.eflag.mark_sensor_1);
|
||||
var chg_run = PUB.AGV.system1.GetChanged(arDev.Narumi.SystemFlag1.eflag.agv_run);
|
||||
var chg_stop = PUB.AGV.system1.GetChanged(arDev.Narumi.SystemFlag1.eflag.agv_stop);
|
||||
//if (chg_run && PUB.AGV.system1.agv_run) PUB.Speak("이동을 시작 합니다");
|
||||
VAR.BOOL[eVarBool.AGVDIR_UP] = PUB.AGV.data.Direction == 'B';
|
||||
// PUB.AGV.signal.mark_sensor = PUB.AGV.signal.mark_sensor;
|
||||
VAR.BOOL[eVarBool.AGV_ERROR] = PUB.AGV.error.Value > 0;
|
||||
VAR.BOOL[eVarBool.EMERGENCY] = PUB.AGV.error.Emergency;
|
||||
|
||||
//모터방향 입력
|
||||
if (PUB.AGV.data.Direction == 'B')
|
||||
PUB.mapctl.agv.CurrentMOTDirection = AGVControl.Models.Direction.Backward;
|
||||
else
|
||||
PUB.mapctl.agv.CurrentMOTDirection = AGVControl.Models.Direction.Forward;
|
||||
|
||||
PUB.mapctl.agv.IsMoving = PUB.AGV.system1.agv_run;
|
||||
PUB.mapctl.agv.IsMarkCheck = PUB.AGV.system1.Mark1_check || PUB.AGV.system1.Mark2_check;
|
||||
|
||||
if (PUB.AGV.signal.mark_sensor == false)
|
||||
{
|
||||
VAR.BOOL[eVarBool.MARK_SENSOROFF] = true;
|
||||
VAR.TIME[eVarTime.MarkSensorOff] = DateTime.Now;
|
||||
PUB.log.Add($"마크센서off를 설정");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == true)
|
||||
{
|
||||
VAR.BOOL[eVarBool.MARK_SENSOROFF] = false;
|
||||
VAR.TIME[eVarTime.MarkSensorOff] = DateTime.Now;
|
||||
PUB.log.Add($"마크센서off를 해제");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//차징상태변경
|
||||
if (_charging != PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
if (PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
VAR.TIME[eVarTime.ChargeStart] = DateTime.Now;
|
||||
PUB.logagv.Add($"충전시작:{VAR.TIME[eVarTime.ChargeStart]}");
|
||||
}
|
||||
_charging = PUB.AGV.system1.Battery_charging;
|
||||
}
|
||||
|
||||
//배터리충전상태
|
||||
if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] != PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
PUB.log.Add($"충전상태전환 {PUB.AGV.system1.Battery_charging}");
|
||||
VAR.BOOL[eVarBool.FLAG_CHARGEONA] = PUB.AGV.system1.Battery_charging;
|
||||
}
|
||||
//자동충전해제시 곧바로 수동 충전되는 경우가 있어 자동 상태를 BMS에 넣는다 230118
|
||||
PUB.BMS.AutoCharge = PUB.AGV.system1.Battery_charging;
|
||||
|
||||
if (PUB.AGV.error.Charger_pos_error != VAR.BOOL[eVarBool.CHG_POSERR])
|
||||
{
|
||||
if (PUB.AGV.error.Charger_pos_error)
|
||||
{
|
||||
PUB.Speak(Lang.충전기위치오류);
|
||||
}
|
||||
VAR.BOOL[eVarBool.CHG_POSERR] = PUB.AGV.error.Charger_pos_error;
|
||||
}
|
||||
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == true && PUB.AGV.signal.mark_sensor == false)
|
||||
{
|
||||
//현재 활성화된 위치를 꺼준다
|
||||
if (this.ctlPos1.GetPositionActive(PUB.Result.CurrentPos))
|
||||
{
|
||||
var ts = VAR.TIME.RUN(eVarTime.MarkSensorOff);
|
||||
if (ts.TotalSeconds >= 2)
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == false)
|
||||
{
|
||||
ctlPos1.SetPositionDeActive();
|
||||
PUB.log.Add($"현재 활성위치를 해제 함");
|
||||
VAR.BOOL[eVarBool.MARK_SENSOROFF] = true;
|
||||
VAR.TIME[eVarTime.MarkSensorOff] = DateTime.Now;
|
||||
PUB.log.Add($"마크센서off를 설정");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == true)
|
||||
{
|
||||
VAR.BOOL[eVarBool.MARK_SENSOROFF] = false;
|
||||
VAR.TIME[eVarTime.MarkSensorOff] = DateTime.Now;
|
||||
PUB.log.Add($"마크센서off를 해제");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//나르미가 멈췄다면 다음 마크 이동 기능이 OFF 된다
|
||||
if (PUB.AGV.system1.agv_stop)
|
||||
VAR.BOOL[eVarBool.NEXTSTOP_MARK] = false;
|
||||
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOR] != PUB.AGV.signal.mark_sensor)
|
||||
{
|
||||
if (PUB.AGV.signal.mark_sensor)
|
||||
//차징상태변경
|
||||
if (_charging != PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
//현재위치를 확정한다
|
||||
var curact = ctlPos1.GetPositionActive(PUB.Result.CurrentPos);
|
||||
if (curact == false)
|
||||
if (PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
PUB.log.Add($"마크센서로인해 현재위치 설정완료:{PUB.Result.CurrentPos}");
|
||||
ctlPos1.SetPositionActive(PUB.Result.CurrentPos);
|
||||
ctlPos1.SetDirection("");
|
||||
ctlPos1.Invalidate();
|
||||
VAR.TIME[eVarTime.ChargeStart] = DateTime.Now;
|
||||
PUB.logagv.Add($"충전시작:{VAR.TIME[eVarTime.ChargeStart]}");
|
||||
}
|
||||
_charging = PUB.AGV.system1.Battery_charging;
|
||||
}
|
||||
VAR.BOOL[eVarBool.MARK_SENSOR] = PUB.AGV.signal.mark_sensor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case arDev.Narumi.DataType.TAG:
|
||||
{
|
||||
//자동 실행 중이다.
|
||||
PUB.log.Add($"AGV 태그수신 : {PUB.AGV.data.TagNo}");
|
||||
PUB.Result.LastTAG = PUB.AGV.data.TagNo.ToString();
|
||||
|
||||
//POT/NOT 보면 일단 바로 멈추게한다
|
||||
if (PUB.Result.CurrentPos == ePosition.POT || PUB.Result.CurrentPos == ePosition.NOT)
|
||||
//배터리충전상태
|
||||
if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] != PUB.AGV.system1.Battery_charging)
|
||||
{
|
||||
PUB.log.Add($"충전상태전환 {PUB.AGV.system1.Battery_charging}");
|
||||
VAR.BOOL[eVarBool.FLAG_CHARGEONA] = PUB.AGV.system1.Battery_charging;
|
||||
}
|
||||
//자동충전해제시 곧바로 수동 충전되는 경우가 있어 자동 상태를 BMS에 넣는다 230118
|
||||
PUB.BMS.AutoCharge = PUB.AGV.system1.Battery_charging;
|
||||
|
||||
if (PUB.AGV.error.Charger_pos_error != VAR.BOOL[eVarBool.CHG_POSERR])
|
||||
{
|
||||
if (PUB.AGV.error.Charger_pos_error)
|
||||
{
|
||||
PUB.Speak(Lang.충전기위치오류);
|
||||
}
|
||||
VAR.BOOL[eVarBool.CHG_POSERR] = PUB.AGV.error.Charger_pos_error;
|
||||
}
|
||||
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == true && PUB.AGV.signal.mark_sensor == false)
|
||||
{
|
||||
//현재 활성화된 위치를 꺼준다
|
||||
if (this.ctlPos1.GetPositionActive(PUB.Result.CurrentPos))
|
||||
{
|
||||
var ts = VAR.TIME.RUN(eVarTime.MarkSensorOff);
|
||||
if (ts.TotalSeconds >= 2)
|
||||
{
|
||||
ctlPos1.SetPositionDeActive();
|
||||
PUB.log.Add($"현재 활성위치를 해제 함");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//나르미가 멈췄다면 다음 마크 이동 기능이 OFF 된다
|
||||
if (PUB.AGV.system1.agv_stop)
|
||||
VAR.BOOL[eVarBool.NEXTSTOP_MARK] = false;
|
||||
|
||||
if (VAR.BOOL[eVarBool.MARK_SENSOR] != PUB.AGV.signal.mark_sensor)
|
||||
{
|
||||
if (PUB.AGV.signal.mark_sensor)
|
||||
{
|
||||
//현재위치를 확정한다
|
||||
var curact = ctlPos1.GetPositionActive(PUB.Result.CurrentPos);
|
||||
if (curact == false)
|
||||
{
|
||||
PUB.log.Add($"마크센서로인해 현재위치 설정완료:{PUB.Result.CurrentPos}");
|
||||
ctlPos1.SetPositionActive(PUB.Result.CurrentPos);
|
||||
ctlPos1.SetDirection("");
|
||||
ctlPos1.Invalidate();
|
||||
}
|
||||
}
|
||||
VAR.BOOL[eVarBool.MARK_SENSOR] = PUB.AGV.signal.mark_sensor;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case arDev.Narumi.DataType.TAG:
|
||||
{
|
||||
var logEMsg = $"Stop by [POT/NOT]";
|
||||
PUB.AGV.AGVMoveStop(logEMsg);
|
||||
PUB.log.AddE(logEMsg);
|
||||
}
|
||||
//자동 실행 중이다.
|
||||
PUB.log.Add($"AGV 태그수신 : {PUB.AGV.data.TagNo}");
|
||||
PUB.Result.LastTAG = PUB.AGV.data.TagNo.ToString();
|
||||
|
||||
//맵데이터에서 현재 위치를 찾는다
|
||||
if (PUB.mapctl.SetCurrentPosition(PUB.AGV.data.TagNo) == false)
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.FLAG_AUTORUN] && PUB.AGV.system1.agv_run)
|
||||
PUB.AGV.AGVMoveStop("unknown tag no");
|
||||
//POT/NOT 보면 일단 바로 멈추게한다
|
||||
if (PUB.Result.CurrentPos == ePosition.POT || PUB.Result.CurrentPos == ePosition.NOT)
|
||||
{
|
||||
var logEMsg = $"Stop by [POT/NOT]";
|
||||
PUB.AGV.AGVMoveStop(logEMsg);
|
||||
PUB.log.AddE(logEMsg);
|
||||
}
|
||||
|
||||
//존재하지 않는 태그가 읽히면 관련 오류를 표시한다.
|
||||
}
|
||||
else
|
||||
{
|
||||
//위치는 찾았다 해당 위치가 내 목적지라면 mark stop기능으로 전환한다
|
||||
//맵데이터에서 현재 위치를 찾는다
|
||||
if (PUB.mapctl.SetCurrentPosition(PUB.AGV.data.TagNo) == false)
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.FLAG_AUTORUN] && PUB.AGV.system1.agv_run)
|
||||
PUB.AGV.AGVMoveStop("unknown tag no");
|
||||
|
||||
//존재하지 않는 태그가 읽히면 관련 오류를 표시한다.
|
||||
}
|
||||
else
|
||||
{
|
||||
//위치는 찾았다 해당 위치가 내 목적지라면 mark stop기능으로 전환한다
|
||||
|
||||
}
|
||||
|
||||
|
||||
////자동, 상하차 모드일때 RFID 가 타겟위치에 올때는 - 멈춤을 설정해준다
|
||||
//if (VAR.BOOL[eVarBool.FLAG_AUTORUN] == true &&
|
||||
// PUB.Result.CurrentPos == PUB.Result.TargetPos &&
|
||||
// PUB.Result.TargetPos != ePosition.NONE &&
|
||||
// (PUB.sm.RunStep == ERunStep.GODOWN ||
|
||||
// PUB.sm.RunStep == ERunStep.GOUP ||
|
||||
// PUB.sm.RunStep == ERunStep.GOHOME ||
|
||||
// PUB.sm.RunStep == ERunStep.GOCHARGE))
|
||||
//{
|
||||
// if (PUB.AGV.data.Sts == 'F' && dirForward == "0") //아래로 내려오고있음
|
||||
// {
|
||||
// PUB.AGV.AGVMoveStop("AGV_DataReceive", arDev.Narumi.eStopOpt.MarkStop);
|
||||
// PUB.Speak( Lang.다음마크위치에서정지합니다);
|
||||
// }
|
||||
// else if (PUB.AGV.data.Sts == 'B' && dirForward == "1")
|
||||
// {
|
||||
// //VAR.BOOL[eVarBool.FLAG_NEXTSTOP_MARK] = true;
|
||||
// PUB.AGV.AGVMoveStop("AGV_DataReceive", arDev.Narumi.eStopOpt.MarkStop);
|
||||
// PUB.Speak(Lang.다음마크위치에서정지합니다);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
break;
|
||||
case arDev.Narumi.DataType.ACK:
|
||||
PUB.logagv.Add($"AGV_[ACK]Receive : {PUB.AGV.ACKData}");
|
||||
break;
|
||||
default:
|
||||
PUB.logagv.Add($"AGV_DataReceive : {e.DataType}");
|
||||
break;
|
||||
|
||||
|
||||
////자동, 상하차 모드일때 RFID 가 타겟위치에 올때는 - 멈춤을 설정해준다
|
||||
//if (VAR.BOOL[eVarBool.FLAG_AUTORUN] == true &&
|
||||
// PUB.Result.CurrentPos == PUB.Result.TargetPos &&
|
||||
// PUB.Result.TargetPos != ePosition.NONE &&
|
||||
// (PUB.sm.RunStep == ERunStep.GODOWN ||
|
||||
// PUB.sm.RunStep == ERunStep.GOUP ||
|
||||
// PUB.sm.RunStep == ERunStep.GOHOME ||
|
||||
// PUB.sm.RunStep == ERunStep.GOCHARGE))
|
||||
//{
|
||||
// if (PUB.AGV.data.Sts == 'F' && dirForward == "0") //아래로 내려오고있음
|
||||
// {
|
||||
// PUB.AGV.AGVMoveStop("AGV_DataReceive", arDev.Narumi.eStopOpt.MarkStop);
|
||||
// PUB.Speak( Lang.다음마크위치에서정지합니다);
|
||||
// }
|
||||
// else if (PUB.AGV.data.Sts == 'B' && dirForward == "1")
|
||||
// {
|
||||
// //VAR.BOOL[eVarBool.FLAG_NEXTSTOP_MARK] = true;
|
||||
// PUB.AGV.AGVMoveStop("AGV_DataReceive", arDev.Narumi.eStopOpt.MarkStop);
|
||||
// PUB.Speak(Lang.다음마크위치에서정지합니다);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
break;
|
||||
case arDev.Narumi.DataType.ACK:
|
||||
PUB.logagv.Add($"AGV_[ACK]Receive : {PUB.AGV.ACKData}");
|
||||
break;
|
||||
default:
|
||||
PUB.logagv.Add($"AGV_DataReceive : {e.DataType}");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[AGV_DataReceive] {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Media.Animation;
|
||||
using AR;
|
||||
using arCtl;
|
||||
using COMM;
|
||||
@@ -113,9 +114,29 @@ namespace Project
|
||||
var ts = VAR.TIME.RUN(eVarTime.LastConn_BAT);
|
||||
if (ts.TotalSeconds > 3)
|
||||
{
|
||||
Console.WriteLine($"bms connect to {PUB.setting.Port_BAT}");
|
||||
PUB.BMS.PortName = PUB.setting.Port_BAT;
|
||||
PUB.BMS.Open();
|
||||
|
||||
PUB.BMS.BMSDataReceive += Bms_BMSDataReceive;
|
||||
PUB.BMS.Message += Bms_Message;
|
||||
PUB.BMS.ChargeDetect += BMS_ChargeDetect;
|
||||
|
||||
VAR.TIME.Update(eVarTime.LastConn_BAT);
|
||||
VAR.TIME.Update(eVarTime.LastConnTry_BAT);
|
||||
}
|
||||
}
|
||||
else if (PUB.BMS.IsValid == false)
|
||||
{
|
||||
var ts = VAR.TIME.RUN(eVarTime.LastConnTry_BAT);
|
||||
if (ts.TotalSeconds > 10)
|
||||
{
|
||||
Console.WriteLine("bms auto disconnect");
|
||||
PUB.BMS.BMSDataReceive -= Bms_BMSDataReceive;
|
||||
PUB.BMS.Message -= Bms_Message;
|
||||
PUB.BMS.ChargeDetect -= BMS_ChargeDetect;
|
||||
PUB.BMS.Close();
|
||||
VAR.TIME.Set(eVarTime.LastConn_BAT,DateTime.Now.AddSeconds(5));
|
||||
}
|
||||
}
|
||||
//ConnectSerialPort(PUB.BMS, PUB.setting.Port_BAT, PUB.setting.Baud_BAT,
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Project
|
||||
var targID = dataStr.Substring(0, 2);
|
||||
var targstr = dataStr.Substring(2);
|
||||
|
||||
if(byte.TryParse(targID,out byte tID))
|
||||
if (byte.TryParse(targID, out byte tID))
|
||||
{
|
||||
if (PUB.setting.XBE_ID == tID)
|
||||
{
|
||||
@@ -61,13 +61,10 @@ namespace Project
|
||||
if (uint.TryParse(dataStr, out uint tagno2))
|
||||
{
|
||||
var currPos = PUB.mapctl.agv.CurrentRFID;///.AGVMoveToRFID(;
|
||||
if (currPos == 0) currPos = 10;
|
||||
var pathRlt = PUB.mapctl.CalculatePath(currPos, tagno2);
|
||||
if (pathRlt.Success == true)
|
||||
{
|
||||
PUB.log.AddI($"New Target:{tagno2}");
|
||||
}
|
||||
else PUB.log.AddE($"Path Error {pathRlt.Message} : {tagno2}");
|
||||
if (PUB.mapctl.SetTargetPosition(tagno2))
|
||||
PUB.log.AddI($"New Target {tagno2}");
|
||||
else
|
||||
PUB.log.AddE($"Path Error {tagno2}");
|
||||
}
|
||||
else PUB.log.AddE($"Path Param Error :{dataStr}");
|
||||
break;
|
||||
|
||||
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>
|
||||
|
||||
@@ -112,6 +112,8 @@ namespace COMM
|
||||
/// 충전시작명령을 전송했다
|
||||
/// </summary>
|
||||
WAIT_CHARGEACK,
|
||||
|
||||
MARKSTOP_ON,
|
||||
|
||||
|
||||
//agv area start ( 64 ~ 95)
|
||||
|
||||
Reference in New Issue
Block a user