67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
using ENIG;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace AGVEmulator
|
|
{
|
|
public partial class fMain
|
|
{
|
|
|
|
private void CAL_Message(object sender, AR.Dev.RS232.MessageEventArgs e)
|
|
{
|
|
|
|
if (e.MsgType == AR.Dev.RS232.MessageType.Send)
|
|
logCAL.Add(">> " + System.Text.Encoding.Default.GetString(e.Data));
|
|
else if (e.MsgType == AR.Dev.RS232.MessageType.Recv)
|
|
logCAL.Add("<< " + System.Text.Encoding.Default.GetString( e.Data));
|
|
else logCAL.Add(e.Message);
|
|
|
|
}
|
|
private void CAL_ProtocReceived(object sender, ENIG.EEProtocol.DataEventArgs e)
|
|
{
|
|
// 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)
|
|
{
|
|
if (data.Length >= 14)
|
|
{
|
|
_remoteStatus.Mode = data[0];
|
|
_remoteStatus.RunSt = data[1];
|
|
_remoteStatus.RunStep = data[2];
|
|
_remoteStatus.RunStepSeq = data[3];
|
|
_remoteStatus.MotorDir = data[4];
|
|
_remoteStatus.MagnetDir = data[5];
|
|
_remoteStatus.ChargeSt = data[6];
|
|
_remoteStatus.CartSt = data[7];
|
|
_remoteStatus.LiftSt = data[8];
|
|
_remoteStatus.ErrorCode = data[9];
|
|
_remoteStatus.LastTag = Encoding.ASCII.GetString(data, 10, 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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|