Commit f8b72bdf LN

agv调度代码修改

1 个父辈 8f212f33
......@@ -39,7 +39,7 @@
<!--流水线监听端口-->
<add key="TCPServerPort" value="5246" />
<!--AGV调度服务器地址-->
<add key="AgvServerIp" value="192.168.103.22" />
<add key="AgvServerIp" value="192.168.103.12" />
<!--IO配置-->
<add key ="DIMS" value ="60"/>
<add key ="DOMS" value ="300"/>
......
......@@ -39,8 +39,9 @@
<Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference>
<Reference Include="Client">
<HintPath>..\..\..\RC1250-ACPackingStore\dll\Client.dll</HintPath>
<Reference Include="Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Client.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
......
using BLL;

using Asa;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -11,35 +12,83 @@ namespace OnlineStore.DeviceLibrary
public class AgvClient
{
private static string ServerIp = ConfigAppSettings.GetValue(Setting_Init.AgvServerIp);
//private string NodeName = "";
private static Client agvClient = null;
public static Dictionary<string, Asa.Actions> actionMap = new Dictionary<string, Asa.Actions>();
private static Client agvClient;
public static Dictionary<string, string> actionMap = new Dictionary<string, string>();
public static List<string> NodeList = new List<string>();
public static void Init( )
public static void Init()
{
try
{
// this.NodeName = nodeID;
if (agvClient == null)
{
agvClient = new Client(ServerIp);
}
actionMap = new Dictionary<string, Asa.Actions>();
foreach(string key in NodeList)
actionMap = new Dictionary<string, string>();
foreach (string key in NodeList)
{
actionMap.Add(key, Asa.Actions.ClientClose);
actionMap.Add(key, AGVAction.None);
}
agvClient.Info += AgvClient_Info;
agvClient.Log += AgvClient_Log;
agvClient.Connected += AgvClient_Connected;
agvClient.Action += AgvClient_Action;
agvClient.Arrive += AgvClient_Arrive;
agvClient.CanEnter += AgvClient_CanEnter;
agvClient.Ready += AgvClient_Ready;
agvClient.Connect();
agvClient.SetNodeID(NodeList.ToArray());
}
catch (Exception ex)
{
LogUtil.error("初始化agvClient " + ServerIp + " 出错:",ex);
LogUtil.error("初始化agvClient " + ServerIp + " 出错:", ex);
}
}
private static void AgvClient_Ready(string id, byte[] content)
{
FeedingEquip equip = getFeedEquip(id);
RFIDData data = new RFIDData(content);
if (equip == null)
{
LogUtil.info("收到 AgvClient_Ready ["+id+"] ["+data.ToData()+"] 未找到对应的设备 ");
return;
}
equip.AgvReady(id,data);
}
private static void AgvClient_CanEnter(string id, byte[] content)
{
FeedingEquip equip = getFeedEquip(id);
RFIDData data = new RFIDData(content);
if (equip == null)
{
LogUtil.info("收到 AgvClient_Ready [" + id + "] [" + data.ToData() + "] 未找到对应的设备 ");
return;
}
equip.AgvCanEnter(id, data);
}
private static void AgvClient_Arrive(string id, byte[] content)
{
FeedingEquip equip = getFeedEquip(id);
RFIDData data = new RFIDData(content);
if (equip == null)
{
LogUtil.info("收到 AgvClient_Ready [" + id + "] [" + data.ToData() + "] 未找到对应的设备 ");
return;
}
equip.AgvArrive(id, data);
}
private static FeedingEquip getFeedEquip(string nodeId)
{
foreach (FeedingEquip feed in LineManager.Line.FeedingEquipMap.Values)
{
if (feed.Config.AgvInName.Equals(nodeId) || feed.Config.AgvOutName.Equals(nodeId))
{
return feed;
}
}
return null;
}
internal static bool ISConnected()
{
......@@ -49,101 +98,48 @@ namespace OnlineStore.DeviceLibrary
}
return agvClient.IsConn;
}
/// <summary>
///02 发送RFID
/// </summary>
/// <param name="NodeName"></param>
internal static void SendRFID(string NodeName, byte[] data)
internal static void SendRFID(string NodeName, string rfid)
{
agvClient.SendRFID(NodeName, data);
agvClient.SendRFID(NodeName, rfid);
}
/// <summary>
/// 10 准备空车
/// </summary>
/// <param name="NodeName"></param>
internal static void ReadyEmpty(string NodeName)
internal static void NeedEnter(string NodeName)
{
agvClient.ReadyEmpty(NodeName);
agvClient.NeedEnter(NodeName);
}
/// <summary>
/// 11 准备小车带料架
/// </summary>
/// <param name="NodeName"></param>
internal static void ReadyShelf(string NodeName)
internal static void NeedLeave(string NodeName)
{
agvClient.ReadyShelf(NodeName);
agvClient.NeedLeave(NodeName);
}
/// <summary>
/// 12 可以进入
/// </summary>
/// <param name="NodeName"></param>
internal static void MayEnter(string NodeName)
{
agvClient.MayEnter(NodeName);
}
/// <summary>
///13 完成进入
/// </summary>
/// <param name="NodeName"></param>
internal static void FinishEnter(string NodeName)
{
agvClient.FinishEnter(NodeName);
}
/// <summary>
/// 14 可以出去
/// </summary>
/// <param name="NodeName"></param>
internal static void MayOut(string NodeName)
internal static void MayLeave(string NodeName)
{
agvClient.MayOut(NodeName);
agvClient.MayLeave(NodeName);
}
/// <summary>
///17 小车离开
/// </summary>
/// <param name="NodeName"></param>
internal static void GetOut(string NodeName)
internal static void IsEnter(string NodeName,bool result)
{
agvClient.GetOut(NodeName);
agvClient.IsEnter(NodeName, result);
}
private static bool AgvClient_Action(string name, Asa.Actions action)
{
if (actionMap.ContainsKey(name))
{
actionMap[name] = action;
}
else
{
actionMap.Add(name, action);
}
return LineManager.Line.FeedAGVProcess(name, action);
}
private static void AgvClient_Connected()
{
agvClient.SetNodeID(NodeList.ToArray());
}
private static void AgvClient_Log(string s)
{
LogUtil.info("AGV "+ ServerIp + " Log:" + s);
LogUtil.info("AGV " + ServerIp + " Log:" + s);
}
private static void AgvClient_Info(string s)
{
LogUtil.info("AGV "+ ServerIp + " Info:" + s);
}
public static Asa.Actions GetAction(string NodeName)
public static string GetAction(string NodeName)
{
if (actionMap.ContainsKey(NodeName))
{
return actionMap[NodeName];
}
return Asa.Actions.ClientClose;
return AGVAction.None;
}
public static void Dispose()
{
......@@ -156,8 +152,16 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("释放 agvClient "+ ServerIp + " 出错:",ex);
LogUtil.error("释放 agvClient " + ServerIp + " 出错:", ex);
}
}
}
public class AGVAction
{
public static string None = "None";
public static string Arrive = "Arrive";
public static string CanEnter = "CanEnter";
public static string GetRFID = "GetRFID";
public static string Ready = "Ready";
}
}
......@@ -402,7 +402,7 @@ namespace OnlineStore.DeviceLibrary
else if (IOValue(IO_Type.SL_Out_Check).Equals(IO_VALUE.HIGH))
{
//线体出口检测到料架,需要通知AGV小车
AgvClient.ReadyEmpty(Config.AgvOutName);
AgvClient.NeedLeave(Config.AgvOutName);
// SendShelfToAGV();
}
......@@ -779,12 +779,17 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_33_BatchAxisToP1))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_34_OutCheck);
InLog("上料完成" + MoveInfo.SLog + ",等待出料线体无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Out_Check, IO_VALUE.LOW));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_34_OutCheck))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_35_OutTopCylinder_Up);
InLog("上料完成" + MoveInfo.SLog + ",出口顶升气缸上升,出料缓冲阻挡上升");
CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
IOMove(IO_Type.SL_Out_StopDown, IO_VALUE.LOW);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_35_OutTopCylinder_Up))
{
//TODO
......@@ -826,14 +831,12 @@ namespace OnlineStore.DeviceLibrary
runStatus = LineRunStatus.Runing;
// MoveInfo.NextMoveStep(LineMoveStep.FI_39_OutLineRun);
InLog("上料完成,料架到达出口处, 通知AGV取空料架, 入料流程结束");
AgvClient.ReadyEmpty(Config.AgvOutName);
AgvClient.NeedLeave(Config.AgvOutName);
}
#endregion
}
private void FI_12_MoveCylinder_Give()
{
if (MoveCylineCanTakeOrGive())
......
......@@ -72,15 +72,14 @@ namespace OnlineStore.DeviceLibrary
StartOutStoreMove(null);
}
else if (IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
{//小车到达处理
{
//小车到达处理
}
else if (IOValue(IO_Type.SL_Out_Check).Equals(IO_VALUE.HIGH))
{
//线体出口检测到料架,需要通知AGV小车
AgvClient.ReadyEmpty(Config.AgvOutName);
AgvClient.NeedLeave(Config.AgvOutName);
}
}
public override bool StartOutStoreMove(InOutParam param)
{
......@@ -255,7 +254,7 @@ namespace OnlineStore.DeviceLibrary
if (tp < Config.BatchAxisP2)
{
OutLog("准备出库料架 " + MoveInfo.SLog + " :检测到料盘,下降的目标高度为【" + tp + "】<【" + Config.BatchAxisP2 + "】,料架已满,直接送出料架");
MoveInfo.NextMoveStep(LineMoveStep.FO_31_BatchAxisToP2);
MoveInfo.NextMoveStep(LineMoveStep.FO_30_BatchAxisToP2);
OutLog("出库移栽 " + MoveInfo.SLog + ":提升伺服到P2点");
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
}
......@@ -273,23 +272,29 @@ namespace OnlineStore.DeviceLibrary
}
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_31_BatchAxisToP2))
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_30_BatchAxisToP2))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_32_TrayLocation_After);
MoveInfo.NextMoveStep(LineMoveStep.FO_31_TrayLocation_After);
OutLog("送出料串: " + MoveInfo.SLog + ": 升降盘定位气缸后退,重置 OutEndSendShelfOut=fasle ,OutStoreCount = 0");
OutEndSendShelfOut = false;
OutStoreHeight = -1;
OutStoreCount = 0;
TrayLCylinderAfter(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_32_TrayLocation_After))
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_31_TrayLocation_After))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_33_BatchAxisToP1);
MoveInfo.NextMoveStep(LineMoveStep.FO_32_BatchAxisToP1);
OutLog("送出料串: " + MoveInfo.SLog + ":提升伺服到P1点,定位气缸下降");
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_33_BatchAxisToP1))
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_32_BatchAxisToP1))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_34_OutCheck);
OutLog("送出料串: " + MoveInfo.SLog + ",等待出料线体无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Out_Check, IO_VALUE.LOW));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_34_OutCheck))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_34_OutTopCylinder_Up);
OutLog("送出料串: " + MoveInfo.SLog + ",出口顶升气缸上升,出料缓冲阻挡上升");
......@@ -337,9 +342,9 @@ namespace OnlineStore.DeviceLibrary
runStatus = LineRunStatus.Runing;
// MoveInfo.NextMoveStep(LineMoveStep.FO_39_OutLineRun);
OutLog("送出料串: " + MoveInfo.SLog + ", 出口线体运转,料架到达出口处, 通知AGV取空料架, 出料结束");
AgvClient.ReadyEmpty(Config.AgvOutName);
AgvClient.NeedLeave(Config.AgvOutName);
}
else if (MoveInfo.MoveStep >= LineMoveStep.FO_211_AxisDownMove && MoveInfo.MoveStep < LineMoveStep.FO_31_BatchAxisToP2)
else if (MoveInfo.MoveStep >= LineMoveStep.FO_211_AxisDownMove && MoveInfo.MoveStep < LineMoveStep.FO_30_BatchAxisToP2)
{
TrayOutProcess();
}
......@@ -378,7 +383,7 @@ namespace OnlineStore.DeviceLibrary
{
targetPosition = Config.BatchAxisP2;
}
OutLog("出库移栽 " + MoveInfo.SLog + " :TrayOutProcess 伺服检测信号亮并且不再P2点,再次下降指定的高度,目标:"+ targetPosition);
OutLog("出库移栽 " + MoveInfo.SLog + " :TrayOutProcess 伺服检测信号亮并且不再P2点,再次下降指定的高度,目标:" + targetPosition);
BatchAxis.AbsMove(MoveInfo, targetPosition, Config.BatchAxis_P2Speed);
}
}
......@@ -467,6 +472,21 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_221_UpdownAxisToP1))
{
if (MoveCylineCanTakeOrGive())
{
MoveInfo.NextMoveStep(LineMoveStep.FO_222_CylinderTake);
OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构回到取料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FO_221_UpdownAxisToP1);
OutLog("紧急出料" + MoveInfo.SLog + ":上料横移机构取料端 前先上升横移气缸");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_222_CylinderTake))
{
//出库结束 TODO
// bool isNeedSendShelf = false;
//判断料架是否满了
......@@ -498,7 +518,7 @@ namespace OnlineStore.DeviceLibrary
}
private void SendOutShelfOut(string msg="")
{
MoveInfo.NextMoveStep(LineMoveStep.FO_31_BatchAxisToP2);
MoveInfo.NextMoveStep(LineMoveStep.FO_30_BatchAxisToP2);
OutStoreHeight = -1;
OutLog("紧急出料完成, " + MoveInfo.SLog + ":"+msg+ ",送出料串,提升伺服到P2点,重置OutStoreHeight=-1");
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
......
......@@ -919,21 +919,5 @@ namespace OnlineStore.DeviceLibrary
return false;
}
#endregion
#region AGV小车判断
internal bool FeedAGVProcess(string name, Asa.Actions action)
{
foreach (FeedingEquip feed in FeedingEquipMap.Values)
{
if (feed.Config.AgvInName.Equals(name) || feed.Config.AgvOutName.Equals(name))
{
return feed.ProcessAGVAction(name, action);
}
}
LogUtil.error("收到agv调度Actions【" + name + "】=【" + action + "】,未找到对应的设备");
return false;
}
#endregion
}
}
......@@ -81,7 +81,7 @@ namespace OnlineStore.DeviceLibrary
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.MOVING, DeviceID);
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.MOVING, DeviceID.ToString());
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_54_CylinderOpen))
......@@ -101,9 +101,6 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 移载装置,放物品到流水线操作
//else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember)
// && MoveInfo.MoveStep.Equals(LineMoveStep.MO_56_CylinderAfter)
// && !SecondMoveInfo.IsInWait)
else if ( MoveInfo.MoveStep.Equals(LineMoveStep.MO_56_CylinderAfter) )
{
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember) && !SecondMoveInfo.IsInWait)
......@@ -123,7 +120,7 @@ namespace OnlineStore.DeviceLibrary
}
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INLINE, trayNum);
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INLINE, "E"+trayNum.ToString().PadLeft(2,'0'));
UpdownDownP2Move(MoveInfo.MoveParam.PlateH);
}
else if (MoveInfo.IsTimeOut(180))
......
......@@ -413,7 +413,7 @@ namespace OnlineStore.DeviceLibrary
{
OutLog("出料 " + MoveInfo.SLog + " : 夹料气缸夹紧,更新料盘位置【" + MoveInfo.MoveParam.WareCode + "】【INBELT】【" + lineId + "】");
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INBELT, lineId);
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INBELT, lineId.ToString());
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_03_CylinderOpen))
......
......@@ -198,7 +198,7 @@ namespace OnlineStore.DeviceLibrary
}
public static string UpdateTrayLoc(string deviceName, string barcode, string status, int locInfo)
public static string UpdateTrayLoc(string deviceName, string barcode, string status, string locInfo)
{
string msg = "";
try
......@@ -211,7 +211,7 @@ namespace OnlineStore.DeviceLibrary
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);//barcode = 料盘的条码
paramMap.Add("status", status); // status = 状态信息, 移栽 = MOVING, 流水线 = INLINE, 皮带线 = INBELT
paramMap.Add("locInfo", locInfo.ToString()); // locInfo = 位置信息,移栽时为移栽编号,流水线时为托盘号,皮带线时为皮带线编号,机器人时为机器人编号
paramMap.Add("locInfo", locInfo); // locInfo = 位置信息,移栽时为移栽编号,流水线时为托盘号,皮带线时为皮带线编号,机器人时为机器人编号
string server = GetAddr(Addr_updateLocInfo, paramMap);
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("UpdateTrayLoc 【" + server + "】【" + resultStr + "】");
......
......@@ -377,20 +377,11 @@ namespace OnlineStore.DeviceLibrary
AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null)
{
// Box_Addr add = GetAddr(StartAddress);
// for (int i = 1; i <= 3; i++)
//{
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff));
if (!result)
{
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 失败:" + aioBox.ErrInfo);
}
// else
// {
// break;
// }
//}
}
else
{
......
......@@ -706,7 +706,7 @@ namespace OnlineStore.DeviceLibrary
FI_33_BatchAxisToP1 = 11033,
/// <summary>
/// 上料完成,判断出料线体是否有料架
/// 上料完成,等待出料线体无料架
/// </summary>
FI_34_OutCheck = 11034,
/// <summary>
......@@ -822,41 +822,43 @@ namespace OnlineStore.DeviceLibrary
FO_218_CylinderGive = 12218,
/// <summary>
/// 料盘移栽:升降伺服到P3
/// 紧急出料移栽:升降伺服到P3
/// </summary>
FO_219_UpdownAxisToP3 = 12219,
/// <summary>
/// 料盘移栽:出料横移机构放松
/// 紧急出料移栽:出料横移机构放松
/// </summary>
FO_220_CylinderSlack = 12220,
/// <summary>
/// 料盘移栽:升降伺服回P1
/// 紧急出料移栽:升降伺服回P1
/// </summary>
FO_221_UpdownAxisToP1 = 12221,
/// <summary>
/// 紧急出料移栽:上料横移机构到取料端
/// </summary>
FO_222_CylinderTake = 12222,
/// <summary>
/// 出料完成,料盘已放入料架,提升伺服到P2点
/// </summary>
FO_31_BatchAxisToP2 = 12331,
FO_30_BatchAxisToP2 = 12330,
/// <summary>
/// 出料完成,升降盘定位气缸后退
/// </summary>
FO_32_TrayLocation_After,
FO_31_TrayLocation_After,
/// <summary>
/// 出料完成,提升伺服到P1点
/// </summary>
FO_33_BatchAxisToP1,
FO_32_BatchAxisToP1,
/// <summary>
/// 出料完成,判断出料线体是否有料架
/// 出料完成,等待出料线体无料架
/// </summary>
// FO_34_OutCheck = 12034,
FO_34_OutCheck ,
/// <summary>
/// 出料完成,出口顶升气缸上升
/// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!